Example #1
0
        public bool SaveAdminSetUp(long id, AdminSetUpModel model)
        {
            if (model == null)
            {
                throw new Exception("Admin SetUp data missing!");
            }
            AdminSetUp adminSetUp = ObjectConverter <AdminSetUpModel, AdminSetUp> .Convert(model);

            if (id > 0)
            {
                adminSetUp = adminSetUpRepository.AdminSetUps.FirstOrDefault(x => x.AdminId == id);
                if (adminSetUp == null)
                {
                    throw new Exception("Admin SetUp not found!");
                }
                adminSetUp.ModifiedBy   = System.Web.HttpContext.Current.User.Identity.Name;
                adminSetUp.ModifiedDate = DateTime.Now;
            }
            else
            {
                adminSetUp.CreatededBy = System.Web.HttpContext.Current.User.Identity.Name;
                adminSetUp.CreatedDate = DateTime.Now;
            }

            adminSetUp.Id       = model.Id;
            adminSetUp.IsActive = model.IsActive;

            adminSetUpRepository.Entry(adminSetUp).State = adminSetUp.AdminId == 0 ? EntityState.Added : EntityState.Modified;
            return(adminSetUpRepository.SaveChanges() > 0);
        }
Example #2
0
        public AdminSetUpModel GetAdminSetUp(long id)
        {
            if (id == 0)
            {
                AdminSetUp adminSetUp = adminSetUpRepository.AdminSetUps.FirstOrDefault(x => x.AdminId == id);
                if (adminSetUp == null)
                {
                    return(new AdminSetUpModel()
                    {
                        IsActive = true
                    });
                }
            }

            return(ObjectConverter <AdminSetUp, AdminSetUpModel> .Convert(adminSetUpRepository.AdminSetUps.FirstOrDefault(x => x.AdminId == id)));
        }