public IHttpActionResult Update(int id, GovernmentUnitModel governmentUnitModel) { var government = _governmentService.GetGovernmentUnitById(id); if (government == null || government.Deleted) { return(NotFound()); } government = governmentUnitModel.ToEntity(government); _governmentService.UpdateGovernmentUnit(government); _accountUserActivityService.InsertActivity("UpdateGovernment", "更新名为 {0} 的单位", government.Name); return(Ok(government.ToModel())); }
public IHttpActionResult Create(GovernmentUnitModel governmentUnitModel) { var government = governmentUnitModel.ToEntity(); if (ModelState.IsValid) { _governmentService.InsertGovernmentUnit(government); //activity log _accountUserActivityService.InsertActivity("AddNewGovernment", "新增名为 {0} 的单位", government.Name); //SuccessNotification(_localizationService.GetResource("Admin.Catalog.Categories.Added")); return(Ok(government.ToModel())); } else { return(BadRequest("类别模型数据错误")); } }
public static GovernmentUnit ToEntity(this GovernmentUnitModel model, GovernmentUnit destination) { return(model.MapTo(destination)); }
public static GovernmentUnit ToEntity(this GovernmentUnitModel model) { return(model.MapTo <GovernmentUnitModel, GovernmentUnit>()); }