Exemplo n.º 1
0
        public ActionResult CreateNewList(ListMainModel model)
        {
            model.UserList.UserID = UserID;

            UserListDO savedObject = UserListBL.SaveUserList(model.UserList);

            if (savedObject.ID > 0)
            {
                TempData["InfoMessage"] = "List created";
                return(RedirectToAction("ViewList", new { id = savedObject.ID }));
            }
            else
            {
                TempData["ErrorMessage"] = "Error occurred while creating list!";
            }

            return(View(model));
        }
Exemplo n.º 2
0
        public static UserListDO SaveUserList(UserListDO inputDO)
        {
            Repository <USR_List> rep = new Repository <USR_List>(MArchiveDataContextProvider.Instance);

            USR_List objectToAdd = null;

            if (inputDO.ID == 0)
            {
                objectToAdd = new USR_List();
                ObjectMapper.MapObjects(inputDO, objectToAdd);
                rep.InsertOnSubmit(objectToAdd);
            }
            else
            {
                objectToAdd = rep.GetAll().Single(x => x.ID == inputDO.ID);
                ObjectMapper.MapObjects(inputDO, objectToAdd);
            }
            rep.DCP.CommitChanges(inputDO.UserID);

            InvalidateCache(CacheAreaKey);

            ObjectMapper.MapObjects(objectToAdd, inputDO);
            return(inputDO);
        }