public DTO.ProductMng.ProductColliPiece UpdateColliPiece(DTO.ProductMng.ProductColliPiece dtoItem, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success, Message = "Update colli piece success" }; try { using (ProductMngEntities context = CreateContext()) { var dbColliPiece = context.ProductColliPiece.Where(o => o.ProductColliPieceID == dtoItem.ProductColliPieceID).FirstOrDefault(); dbColliPiece.PieceID = dtoItem.PieceID; dbColliPiece.Colli = dtoItem.Colli; dbColliPiece.Pcs = dtoItem.Pcs; dbColliPiece.ColliPieceDescription = dtoItem.ColliPieceDescription; context.SaveChanges(); } return(dtoItem); } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; notification.DetailMessage.Add(ex.Message); if (ex.GetBaseException() != null) { notification.DetailMessage.Add(ex.GetBaseException().Message); } return(dtoItem); } }
public IHttpActionResult UpdateColliPiece(DTO.ProductMng.ProductColliPiece dtoItem) { Library.DTO.Notification notification; BLL.ProductMng bll = new BLL.ProductMng(Helper.AuthHelper.GetCurrentUserFolder(ControllerContext)); object item = bll.UpdateColliPiece(dtoItem, ControllerContext.GetAuthUserId(), out notification); return(Ok(new Library.DTO.ReturnData <object>() { Data = item, Message = notification })); }
public DTO.ProductMng.ProductColliPiece CreateColliPiece(int productColliID, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success, Message = "Create set ean code success" }; DTO.ProductMng.ProductColliPiece dtoColliPiece = new DTO.ProductMng.ProductColliPiece(); dtoColliPiece.ProductColliPieceID = -1; try { using (ProductMngEntities context = CreateContext()) { var dbColli = context.ProductColli.Where(o => o.ProductColliID == productColliID).FirstOrDefault(); ProductColliPiece dbColliPiece = new ProductColliPiece(); dbColli.ProductColliPiece.Add(dbColliPiece); dbColliPiece.Pcs = 1; dbColliPiece.Colli = 1; //if product is not SET then PieceID is same ProductID int?productID = dbColli.ProductSetEANCode.ProductID; var x = context.ProductMng_Product_View.Where(o => o.ProductID == productID).FirstOrDefault(); if (x == null) { throw new Exception("Could not find product type of product"); } string productTypeNM = x.ProductTypeNM; if (productTypeNM != "SET") { dbColliPiece.PieceID = productID; } //save data context.SaveChanges(); //reload data to dto dtoColliPiece.ProductColliPieceID = dbColliPiece.ProductColliPieceID; dtoColliPiece.Pcs = dbColliPiece.Pcs; dtoColliPiece.Colli = dbColliPiece.Colli; dtoColliPiece.PieceID = dbColliPiece.PieceID; dtoColliPiece.PiceDescription = context.ProductMng_ProductColliPiece_View.Where(o => o.ProductColliPieceID == dtoColliPiece.ProductColliPieceID).FirstOrDefault().PiceDescription; } return(dtoColliPiece); } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; notification.DetailMessage.Add(ex.Message); if (ex.GetBaseException() != null) { notification.DetailMessage.Add(ex.GetBaseException().Message); } return(dtoColliPiece); } }
//update public object UpdateColliPiece(DTO.ProductMng.ProductColliPiece dtoItem, int iRequesterID, out Library.DTO.Notification notification) { return(factory.UpdateColliPiece(dtoItem, out notification)); }