public Boolean SaveMandatoryImages(AdditionalImage item) { //////////////////////////////////// // INSPECTION_COMPARTTYPE_IMAGES DAL.INSPECTION_COMPARTTYPE_IMAGES record = new DAL.INSPECTION_COMPARTTYPE_IMAGES(); // FK ID record.CompartTypeMandatoryImageId = item.ServerId; // FK ID record.InspectionId = _InspectionAuto; // Side record.Side = item.Side; // FileName if (item.ImageFileName != null && !item.ImageFileName.Equals("")) { byte[] image = GetUploadImageData(item.ImageFileName); record.Data = image; } // Comment record.Comment = item.ImageComment; // Title record.Title = item.ImageTitle; // INSERT _INSPECTION_COMPARTTYPE_IMAGES.Add(record); return true; }
public async Task SaveAddtImages(List <IFormFile> additionalImages, Product lastProduct) { int productId = lastProduct.Id; var webRoot = _env.ContentRootPath; var path = Path.Combine(webRoot, "wwwroot", "images", "products", productId.ToString(), "additionalImages"); if (!Directory.Exists(path)) { DirectoryInfo dir = Directory.CreateDirectory(path); } var addtImages = new List <AdditionalImage>(); foreach (var img in additionalImages) { var stream = new FileStream(Path.Combine(path, img.FileName), FileMode.Create); await img.CopyToAsync(stream); var newImage = new AdditionalImage() { ProductId = productId, ImageLink = "/images/products/" + lastProduct.Id.ToString() + "/additionalImages/" + img.FileName }; addtImages.Add(newImage); stream.Close(); } await _addtImgRepository.Add(addtImages); }
public TextAndImageContent CreateContent(XueLeMeContext context, string text, IEnumerable <string> images) { var content = new TextAndImageContent { Text = text, }; context.TextAndImageContents.Add(content); context.SaveChanges(); foreach (var image in images) { var apply = new AdditionalImage { ImageFileMD5 = image, TextAndImageContentId = content.Id, }; context.AdditionalImages.Add(apply); } context.SaveChanges(); return(content); }
public Boolean SaveAdditionalImages(AdditionalImage item) { //////////////////////////////////// // INSPECTION_COMPARTTYPE_RECORD DAL.INSPECTION_COMPARTTYPE_RECORD record = new DAL.INSPECTION_COMPARTTYPE_RECORD(); // FK ID record.CompartTypeAdditionalId = item.ServerId; // FK ID record.InspectionId = _InspectionAuto; // MeasureNumber record.MeasureNumber = 1; // ToolId TrackTool tool = new TrackTool(); int Id = -1; if (item.ToolCode.ToLower().Equals("observation")) { Id = tool.GetIdByToolCode("OB"); } else if (item.ToolCode.ToLower().Equals("yes/no")) { Id = tool.GetIdByToolCode("YES/NO"); } else { Id = tool.GetIdByToolCode("R"); } record.ToolId = Id; // Reading if (item.ToolCode.ToLower().Equals("observation")) { record.ObservationNote = item.Reading; } else { record.Reading = System.Convert.ToDecimal(item.Reading); } // Side record.Side = item.Side; // INSERT _INSPECTION_COMPARTTYPE_RECORD.Add(record); _context.SaveChanges(); ////////////////// // Image record if (item.ImageFileName == null || item.ImageFileName.Equals("")) return true; DAL.INSPECTION_COMPARTTYPE_RECORD_IMAGES recordImg = new DAL.INSPECTION_COMPARTTYPE_RECORD_IMAGES(); // FK recordImg.RecordId = record.Id; // FileName byte[] image = GetUploadImageData(item.ImageFileName); recordImg.Data = image; // Comment recordImg.Comment = item.ImageComment; // Title recordImg.Title = item.ImageTitle; // INSERT _INSPECTION_COMPARTTYPE_RECORD_IMAGES.Add(recordImg); return true; }
public async Task Delete(AdditionalImage addtImage) { _db.AdditionalImages.Remove(addtImage); await _db.SaveChangesAsync(); }