using System.Collections.Generic; namespace ContractService.Views.Shared.Modals { public class ModalViewModel { public ModalViewModel() { IsCenter = true; ModalId = "modal"; } public ModalViewModel(string header, string modalId = "modal", int footer = 0, string sizeClass = "lg", int? width = null) : this() { Header = new ModalHeaderViewModel(header); Footer = footer + ""; ModalId = modalId; Width = width; SizeClass = sizeClass; } public ModalViewModel(string header1, string header2, string modalId = "modal", int footer = 0, string sizeClass = "lg", int? width = null) : this() { Header = new ModalHeaderViewModel(header1, header2); Footer = footer + ""; ModalId = modalId; Width = width; SizeClass = sizeClass; IsCenter = true; } public ModalViewModel(string header, ModalBodyViewModel body, string modalId = "modal", string footer = "0", string sizeClass = "lg", int? width = null) : this() { Header = new ModalHeaderViewModel(header); Body = body; Body.ModalId = modalId; Footer = footer; ModalId = modalId; Width = width; SizeClass = sizeClass; IsCenter = true; } public ModalViewModel(string header1, string header2, ModalBodyViewModel body, string modalId = "modal", int footer = 0, string sizeClass = "lg", int? width = null) : this() { Header = new ModalHeaderViewModel(header1, header2); Body = body; if (body != null) { Body.ModalId = modalId; } Footer = footer + ""; ModalId = modalId; Width = width; SizeClass = sizeClass; } public ModalViewModel(ModalHeaderViewModel header, ModalBodyViewModel body, string modalId = "modal", int footer = 0, string sizeClass = "lg", int? width = null) : this() { Header = header; Body = body; Body.ModalId = modalId; Footer = footer + ""; ModalId = modalId; Width = width; SizeClass = sizeClass; } public ModalHeaderViewModel Header { get; set; } public ModalBodyViewModel Body { get; set; } public string Footer { get; set; } public string ModalId { get; set; } public int? Width { get; set; } public string SizeClass { get; set; } public bool IsCenter { get; set; } public ModalViewModel SetModalId(string id) { ModalId = id; return this; } public ModalViewModel SetHeader(string header1, string header2 = null) { Header = new ModalHeaderViewModel(header1, header2); return this; } public ModalViewModel SetHeader(ModalHeaderViewModel header) { Header = header; return this; } public ModalViewModel SetBody(ModalBodyViewModel body) { Body = body; return this; } public ModalViewModel SetInputs(List inputs, string formId = "form") { Body = new ModalBodyViewModel(inputs, formId, ModalId); return this; } public ModalViewModel SetSpecials(List inputs) { if (Body != null) { Body.Specials = inputs; } return this; } public ModalViewModel SetFooter(string footer) { Footer = footer; return this; } public ModalViewModel SetFooter(int footer) { Footer = footer + ""; return this; } public ModalViewModel SetSize(string sizeClass) { SizeClass = sizeClass; return this; } public ModalViewModel SetSize(int width) { Width = width; return this; } /// ///取消垂直居中 (默认垂直居中) /// /// public ModalViewModel SetNotCenter() { IsCenter = false; return this; } } }