public Result Add(AuthentyDto dto, UserType roleId) { try { var rlt = UnitOfWorkService.Execute(() => { var id = _authentyRepository.InsertAndGetId(dto.MapTo <AuthentyEntity>()); var orgId = _staffRepository.GetOrgId(dto.SalesMan).OrgId; var dataInOrg = new DataInOrgEntity { DataId = id, DataType = (int)DataType.Authenty, OrgId = orgId, RoleId = ((int)roleId).ToString() }; var dataRlt = _dataInOrgRepository.Inserts(dataInOrg); if (id.IsNullOrEmpty() && !dataRlt) { return(new Result(false, "数据库写入失败")); } return(new Result { Status = true }); }); return(rlt); } catch (Exception ex) { Logger.Error("添加实名认证发生错误", ex); return(new Result(false, "实名认证报错")); } }
public Result Update(AuthentyDto dto) { try { var entity = dto.MapTo <AuthentyEntity>(); var rlt = UnitOfWorkService.Execute(() => _authentyRepository.Update(entity)); if (rlt) { return new Result { Status = true } } ; return(new Result { Status = false, Message = "数据库操作失败" }); } catch (Exception ex) { Logger.Error("update authenty error", ex); return(new Result { Status = false, Message = "内部服务器错误" }); } }
public async Task <Result> Modify(AuthentyDto dto, string opt) { var files = Request.Form.Files; if (files.Count > 0) { var stream = files[0].OpenReadStream(); var br = new BinaryReader(stream); var image = br.ReadBytes((int)stream.Length); var memory = new MemoryStream(image) { Position = 0 }; var documentManager = ObjectContainer.Resolve <IDocumentManager>(); var streamId = documentManager.Upload($"Licence_{DateTime.Now.ToString19()}", memory); stream.Close(); br.Close(); memory.Close(); dto.Licence = streamId; } return(await Task.Run(() => { if (opt.Equals("add"))//新增 { dto.CreateDate = DateTime.Now; return _authentyService.Add(dto, LoginInfo.Role); } //修改 return _authentyService.Update(dto); })); }
public IActionResult Modify(string opt, string id) { ViewBag.opt = opt; ViewBag.customer = GetCustomerList(); var model = new AuthentyDto(); if (opt.Equals("update")) { model = _authentyService.Get(id); } return(View(model)); }
public async Task <JsonResult> Modify(AuthentyDto dto, List <IFormFile> formFiles) { return(await Task.Run(() => { try { var files = Request.Form.Files; var stream = files[0].OpenReadStream(); var br = new BinaryReader(stream); var image = br.ReadBytes((int)stream.Length); var memory = new MemoryStream(image) { Position = 0 }; var documentManager = ObjectContainer.Resolve <IDocumentManager>(); var streamId = documentManager.Upload($"Licence{DateTime.Now.ToString19()}", memory); stream.Close(); br.Close(); memory.Close(); var name = Request.Form["Name"]; var telePhone = Request.Form["Telephone"]; var address = Request.Form["Address"]; var email = Request.Form["Email"]; var phone = Request.Form["Phone"]; var createDate = Request.Form["CreateDate"]; dto.Id = LoginInfo.Id; dto.Licence = streamId; dto.Name = name; dto.Telephone = telePhone; dto.Address = address; dto.Email = email; dto.Phone = phone; dto.CreateDate = DateTime.Now; dto.SalesMan = _customerService.Get(LoginInfo.Id).SalesMan; var rlt = _authentyService.Add(dto, 0); return Json(rlt); } catch (Exception e) { Logger.Error("Licence上传错误", e); return Json(new Result(false, "服务器内部错误,请联系技术人员")); } })); }