Esempio n. 1
0
        public ActionResult Delete(string[] ids)
        {
            try
            {
                if (ids.Length != 0)
                {
                    var systemSettings =
                        from id in ids
                        select _systemSettingService.GetById(int.Parse(id));

                    _systemSettingService.BatchDelete(systemSettings);
                }
            }
            catch (Exception ex)
            {
                LogText.Log(Concat("SystemSetting.Delete: ", ex.Message));
            }

            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public JsonResult Add(UserViewModel model)
        {
            if (ModelState.IsValid)
            {
                //if password null set defualt value
                if (string.IsNullOrEmpty(model.Password))
                {
                    var defualtPassword = _systemSettingService.GetById((int)SystemSettingEnum.DefualtPassword).Value;
                    model.Password = defualtPassword;
                }
                var EntityMapped = Mapper.Map <User>(model);
                EntityMapped.CreatedDate = DateTime.Now;

                _UserService.Add(EntityMapped);
                return(Json(new { data = model, success = true }, JsonRequestBehavior.AllowGet));
            }
            var errors = ModelState.GetDistinctModelErrors();

            return(Json(new { data = model, success = false, ErrorsList = errors }, JsonRequestBehavior.AllowGet));
        }