public static bool Save(Models.Portal portal, string userId = null) { userId = string.IsNullOrEmpty(userId) ? Account.AuditId : userId; if (!IsDuplicate(portal)) { var portals = Portal.GetPortals(); if (portal.Default) { foreach (var p in portals.Where(p => p.Default)) { p.Default = false; Repository.Current.StoreResource("Portal", null, p, userId); } } else if (!portals.Exists(p => p.Default && p.Id != portal.Id)) { throw new Exception(string.Format(Localization.GetLocalization(LocalizationType.Exception, "DefaultPortalRequired.Error", "At least one portal must be marked as the default.", "Core"), "Portal")); } Repository.Current.StoreResource("Portal", null, portal, userId); } else { throw new Exception(string.Format(Localization.GetLocalization(LocalizationType.Exception, "DuplicateResource.Error", "{0} already exists. Duplicates Not Allowed.", "Core"), "Portal")); } return(true); }
public static bool IsDuplicate(Models.Portal portal) { var p = GetPortal(portal.Name); if (p != null) { return(p.Id != portal.Id); } return(false); }
public static int Register(Models.Portal portal) { var count = 0; if (!Portal.Exists(portal)) { Logging.Logger.InfoFormat("Registering portal: {0}", portal.Name); Portal.Save(portal, Account.AuditId); count++; } return(count); }
public ActionResult Index() { ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application."; pnet.Models.Portal oportal = new Models.Portal(); oportal.ID = 1; oportal.Name = "conmeno"; //oportal.Products.Add(new Models.Product(1, "product1")); //oportal.Products.Add(new Models.Product(2, "product1")); //oportal.Products.Add(new Models.Product(3, "product2")); Models.Product oproduct = new Models.Product(); oproduct.ID = 32; oproduct.Name = "phuong"; string temp = ""; temp = pnet.Models.Utility.Serialize(oproduct, true); ViewBag.hehe = temp; return View(); }
public static bool Exists(Models.Portal portal) { return(GetPortal(portal.Name) != null); }