Example #1
0
        public ActionResult OrgEdit(OrgModel model)
        {
            model.Provider = Provider;
            if (model.Command == "save")
            {
                bool adding = false;
                if (model.OrgID == 0)
                {
                    adding       = true;
                    model.Active = true; //new orgs are always active
                }

                if (model.Save())
                {
                    //when OrgID is zero (adding a new Org) the page should reload so we can add addresses and departments
                    if (adding)
                    {
                        return(RedirectToAction("OrgEdit", new { model.OrgID }));
                    }
                    else
                    {
                        return(RedirectToAction("Org"));
                    }
                }
            }
            else
            {
                model.Load();
            }

            return(View(model));
        }
Example #2
0
        public void CanSaveOrg()
        {
            IClient currentUser = new LNF.Data.ClientItem
            {
                ClientID = 1301,
                UserName = "******",
                LName    = "Getty",
                FName    = "James"
            };

            var model = new OrgModel()
            {
                CurrentUser = currentUser,
                OrgName     = string.Format("Test Org [{0:yyyyMMddHHmmss}]", DateTime.Now),
                OrgTypeID   = 2
            };

            var result  = model.Save();
            var message = model.GetMessage();

            Assert.IsNull(message);
            Assert.IsTrue(result);

            var alog = DataSession.Query <ActiveLog>().FirstOrDefault(x => x.TableName == "Org" && x.Record == model.OrgID);

            Assert.IsNotNull(alog);
            Assert.AreEqual(alog.EnableDate, DateTime.Now.Date);
            Assert.IsNull(alog.DisableDate);

            Console.WriteLine(model.OrgID);
        }
Example #3
0
        public ActionResult Save(OrgModel org)
        {
            if (ModelState.IsValid)
            {
                IOrgDao orgDao = _factory.CreateOrgDao();
                org.Save(orgDao);
                if (org.Parent == null)
                {
                    return(RedirectToAction("Index"));
                }
                return(RedirectToAction("Index", new { id = org.Parent.Id }));
            }

            return(View(String.IsNullOrEmpty(org.Id) ? "Create" : "Edit", org));
        }