public ActionResult Add(RegisterAddDTO dto) { UserLoginDTO lng = Session["UserLoginInfo"] as UserLoginDTO; dto.UserInfo = lng.UserInfo(); dto.AttachmentIDs = new List <RegisterAttachmentDTO>(); HttpContext.Request.Files.AllKeys.Select(key => HttpContext.Request.Files[key]).Where(p => !string.IsNullOrEmpty(p.FileName)).ToList().ForEach(p => { var att = new RegisterAttachmentDTO { AttachmentID = Guid.NewGuid(), AttachmentName = p.FileName, AttachmentSize = p.ContentLength, }; p.SaveAs(Const.RealBccePath(att.AttachmentID.ToString())); dto.AttachmentIDs.Add(att); }); var pt = ProductManagementProvider.GetProductType(dto.ProductTypeID.Value); var pr = ProductManagementProvider.GetOneProductLine(dto.ProductLineID.Value); dto.ProductLineName = pr.Object.ProductLineName; dto.ProductTypeName = pt.Object.ProductTypeName; var result = _RegisterService.Add(dto); return(new JsonResult(result)); }
/// <summary> /// 添加 /// </summary> public DocumentResultDTO Add(RegisterAddDTO model) { try { var token = model.UserInfo as UserInfoDTO; var entity = new Document_Register { RegisterID = Guid.NewGuid(), ProductTypeID = model.ProductTypeID, ProductTypeName = model.ProductTypeName, ProductLineID = model.ProductLineID, ProductLineName = model.ProductLineName, ProductNo = model.ProductNo, Title = model.Title, ValidDate = model.ValidDate, PublisherID = token.UserID, Publisher = token.FullName, PublishDate = DateTime.Now, UpdateDate = null, }; if (model.AttachmentIDs != null) { document.Document_RegisterAttachment.AddRange(model.AttachmentIDs.Select(p => new Document_RegisterAttachment { AttachmentID = p.AttachmentID, AttachmentName = p.AttachmentName, AttachmentSize = p.AttachmentSize, RegisterID = entity.RegisterID })); document.SaveChanges(); } document.Document_Register.Add(entity); document.SaveChanges(); return(new DocumentResultDTO { success = true }); } catch (Exception ex) { return(new DocumentResultDTO { success = false, message = ex.Message }); } }
public DocumentResultDTO Add(RegisterAddDTO model) { return(_RegisterService.Add(model)); }