public ProductFashtionImagesDto get(string id) { try { ProductFashtionImages bb = _context.ProductFashtionImages.Find(id); _context.Entry(bb).Reference(b => b.ImagesFashtion).Load(); _context.Entry(bb).Reference(b => b.ProductFashtion).Load(); return(mapper.Map <ProductFashtionImages, ProductFashtionImagesDto>(bb)); } catch (Exception) { return(null); } }
public string create(ProductFashtionImagesDto tProductFashtionImagesDto) { try { ProductFashtionImages tProductFashtionImagesNew = mapper.Map <ProductFashtionImagesDto, ProductFashtionImages>(tProductFashtionImagesDto); tProductFashtionImagesNew.Id = Guid.NewGuid().ToString(); // tProductFashtionImagesNew.CreateDate = DateTime.Now; _context.ProductFashtionImages.Add(tProductFashtionImagesNew); _context.SaveChanges(); return("0"); } catch (Exception) { return("1"); } }
public string delete(string id) { try { ProductFashtionImages tProductFashtionImagesRemove = _context.ProductFashtionImages.Find(id); if (tProductFashtionImagesRemove == null) { return("1"); } _context.ProductFashtionImages.Remove(tProductFashtionImagesRemove); _context.SaveChanges(); return("0"); } catch (Exception) { return("1"); } }
public string lockItem(string id) { try { ProductFashtionImages tProductFashtionImagesBlock = _context.ProductFashtionImages.Find(id); if (tProductFashtionImagesBlock == null) { return("1"); } tProductFashtionImagesBlock.Status = false; _context.ProductFashtionImages.Update(tProductFashtionImagesBlock); _context.SaveChanges(); return("0"); } catch (Exception) { return("1"); } }
//Update public string update(ProductFashtionImagesDto tProductFashtionImagesDto) { try { ProductFashtionImages tProductFashtionImagesUpdate = _context.ProductFashtionImages.Find(tProductFashtionImagesDto.Id); if (tProductFashtionImagesUpdate == null) { return("1"); } tProductFashtionImagesUpdate.Id = tProductFashtionImagesDto.Id; tProductFashtionImagesUpdate.ImagesFashtionId = tProductFashtionImagesDto.ImagesFashtionId; tProductFashtionImagesUpdate.ProductFashtionId = tProductFashtionImagesDto.ProductFashtionId; tProductFashtionImagesUpdate.Status = tProductFashtionImagesDto.Status; _context.ProductFashtionImages.Update(tProductFashtionImagesUpdate); _context.SaveChanges(); return("0"); } catch (Exception) { return("1"); } }