Esempio n. 1
0
        public ActionResult CreateOrEdit(ProfileTypeModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (model.Id == 0)
                    {
                        var entity = model.ToEntity <ProfileType>();
                        _profileTypeService.Insert(entity);
                    }
                    else
                    {
                        var entity = _profileTypeService.GetById(model.Id);
                        if (entity == null)
                        {
                            return(AjaxResult(AjaxProcessResult.NotFound));
                        }

                        entity = model.ToEntity(entity);
                        _profileTypeService.Update(entity);
                    }
                }
                catch (Exception ex)
                {
                    _logger.WriteLog("Failed to create or edit ProfileType.", ex, null);
                    return(AjaxResult(AjaxProcessResult.Failed));
                }
            }
            return(AjaxResult(AjaxProcessResult.Success));
        }