public ActionResult ComentWorkOrderImage(CommentImageModel model) { if (!_imageService.SaveDescriptionsForPhoto(model)) { _log.InfoFormat("Add description to image failed"); return(Error("Add description to image failed", $"There is no SageImageWorkOrder for Workorder, or SageImageWorkOrder item dont dontain Image. Add description to image failed")); } _log.InfoFormat("Add image for workorder success"); return(Success()); }
public bool SaveDescriptionsForPhoto(CommentImageModel model) { var imagesDb = this.repository.SearchFor <SageImageWorkOrder>(x => x.WorkOrder == model.IdWorkorder).SingleOrDefault(); if (imagesDb != null && imagesDb.Images != null) { var image = imagesDb.Images.FirstOrDefault(x => x.Id == model.IdImage); if (image != null) { imagesDb.Images.Remove(image); image.Description = model.Description; imagesDb.Images.Add(image); this.repository.Update(imagesDb); _hub.UpdateWorkOrderPicture(imagesDb); return(true); } } return(false); }