public IActionResult QiyeEdit(QiyeViewModel model) { var response = ResponseModelFactory.CreateInstance; string guid = model.QiyeUuid; if (ConfigurationManager.AppSettings.IsTrialVersion) { response.SetIsTrial(); return(Ok(response)); } using (_dbContext) { var entity = _dbContext.Qiye.FirstOrDefault(x => x.QiyeUuid == Guid.Parse(guid)); entity.QiyeName = model.QiyeName; entity.QiyeAddress = model.QiyeAddress; entity.QiyeType = model.QiyeType; entity.Faren = model.Faren; entity.Guimo = model.Guimo; entity.Phone = model.Phone; int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("编辑", "成功:编辑:企业信息一条数据", _dbContext); } response.SetSuccess("修改成功"); return(Ok(response)); } }
public IActionResult QiyeCreate(QiyeViewModel model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { var entity = new HaikanSmartTownCockpit.Api.Entities.Qiye(); entity.QiyeUuid = Guid.NewGuid(); entity.QiyeName = model.QiyeName; entity.QiyeAddress = model.QiyeAddress; entity.QiyeType = model.QiyeType; entity.Faren = model.Faren; entity.Guimo = model.Guimo; entity.Phone = model.Phone; entity.AddTime = DateTime.Now.ToString("yyyy-MM-dd"); entity.AddPeople = AuthContextService.CurrentUser.DisplayName; entity.IsDeleted = 0; _dbContext.Qiye.Add(entity); int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("添加", "成功:添加:企业信息一条数据", _dbContext); } response.SetSuccess("添加成功"); return(Ok(response)); } }