public OperateResultDTO Add(CredentialOperateDTO model) { var credential = new fcpa_CredentialInfo() { ID = model.ID }; fcpa.fcpa_CredentialInfo.Add(credential); return(AddOrUpdate(model, credential, false)); }
public OperateResultDTO Update(CredentialOperateDTO model) { var credential = fcpa.fcpa_CredentialInfo.Find(model.ID); if (credential == null) { return new OperateResultDTO { message = "记录不存在", success = false } } ; return(AddOrUpdate(model, credential, true)); }
private OperateResultDTO AddOrUpdate(CredentialOperateDTO model, fcpa_CredentialInfo credential, bool update) { var distributor = fcpa.fcpa_DistributorInfo.Find(model.DistributorID); var caUser = fcpa.fcpa_CredentialInfo.Where(p => p.fcpa_DistributorInfo.DistributorID == distributor.DistributorID && p.Name == model.Name).Count(); if (update) { if (caUser > 1) { return new OperateResultDTO { message = string.Format("'{0}'已经存在,不要重复添加", model.Name), success = false } } ; } else { if (caUser > 0) { return new OperateResultDTO { message = string.Format("'{0}'已经存在,不要重复添加", model.Name), success = false } } ; } credential.fcpa_DistributorInfo = distributor; credential.Name = model.Name; credential.Department = model.Department; credential.Title = model.Title; credential.CompletedDate = model.CompletedDate; credential.ExpireDate = model.ExpireDate; credential.OffWork = model.OffWork; credential.OffWorkDate = model.OffWorkDate; credential.Domain1 = model.Domain1; credential.Domain2 = model.Domain2; credential.Remark = model.Remark; credential.UpdateDate = DateTime.Now; credential.Certificate = model.Certificate; StatusJob.StatusChange(credential); fcpa.SaveChanges(); return(new OperateResultDTO { success = true }); }
private OperateResultDTO AddOrUpdate() { var request = HttpContext.Request; var files = request.Files; CredentialOperateDTO model = new CredentialOperateDTO { ID = string.IsNullOrEmpty(request.Params["ID"]) ? Guid.NewGuid() : Guid.Parse(request.Params["ID"]), DistributorID = request.Params["DistributorID"], Name = request.Params["Name"], Department = request.Params["Department"], Title = request.Params["Title"], CompletedDate = DateTime.Parse(request.Params["CompletedDate"]), ExpireDate = DateTime.Parse(request.Params["ExpireDate"]), OffWork = bool.Parse(request.Params["OffWork"]), Domain1 = request.Params["Domain1"].ToBool(), Domain2 = request.Params["Domain2"].ToBool(), Remark = request.Params["Remark"], }; if (model.OffWork) { model.OffWorkDate = DateTime.Parse(request.Params["OffWorkDate"]); } if (files.AllKeys.Contains("Certificate") && !string.IsNullOrEmpty(files["Certificate"].FileName)) { files["Certificate"].SaveAs(Const.RealCredentialPath(model.ID.ToString())); model.Certificate = model.ID.ToString(); } if (string.IsNullOrEmpty(request.Params["ID"])) { return(FcpaProvider.Add(model)); } else { return(FcpaProvider.Update(model)); } }
public static OperateResultDTO Update(CredentialOperateDTO dto) { return(PostAPI <OperateResultDTO>(WebConfiger.FcpaServicesUrl + "Credentials/Update", dto)); }
public OperateResultDTO Update(CredentialOperateDTO dto) { return(_FcpaService.Update(dto)); }
public OperateResultDTO Add(CredentialOperateDTO dto) { return(_FcpaService.Add(dto)); }