Ejemplo n.º 1
0
        private static ItemWarehouse getEntityByModel(ItemWarehouseModel model, int count)
        {
            if (model == null)
                return null;

            ItemWarehouse entity = new ItemWarehouse();

            if (count == 0)
            {
                entity.CreateBy = AuthenticationHelper.UserId;
                entity.CreateDate = DateTime.Now;
            }
            else
            {
                entity.CreateBy = model.CreateBy;
                entity.CreateDate = model.CreateDate;
            }

            entity.EndDate = model.EndDate;
            entity.Id = model.Id;
            entity.ItemId = model.ItemId;
            entity.SOBId = model.SOBId;
            entity.StartDate = model.StartDate;
            entity.UpdateBy = AuthenticationHelper.UserId;
            entity.UpdateDate = DateTime.Now;
            entity.WarehouseId = model.WarehouseId;
            return entity;
        }
Ejemplo n.º 2
0
 public static void DeleteItemDetail(ItemWarehouseModel model)
 {
     ItemModel item = SessionHelper.Item;
     ItemWarehouseModel itemWarehouse = item.ItemWarehouses.FirstOrDefault(x => x.Id == model.Id);
     item.ItemWarehouses.Remove(itemWarehouse);
 }
Ejemplo n.º 3
0
        public static void UpdateItemDetail(ItemWarehouseModel model)
        {
            ItemModel item = SessionHelper.Item;

            item.ItemWarehouses.FirstOrDefault(x => x.Id == model.Id).EndDate = model.EndDate;
            item.ItemWarehouses.FirstOrDefault(x => x.Id == model.Id).StartDate = model.StartDate;
            item.ItemWarehouses.FirstOrDefault(x => x.Id == model.Id).WarehouseId = model.WarehouseId;
        }
Ejemplo n.º 4
0
 public static void InsertItemDetail(ItemWarehouseModel model)
 {
     ItemModel item = SessionHelper.Item;
     item.ItemWarehouses.Add(model);
 }
Ejemplo n.º 5
0
 public ActionResult DeletePartial(ItemWarehouseModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             ItemModel header = SessionHelper.Item;
             ItemHelper.DeleteItemDetail(model);
             SessionHelper.Item = header;
             IList<ItemWarehouseModel> itemWarehouses = ItemHelper.GetItemWarehouses();
             return PartialView("createPartial", itemWarehouses);
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
         ViewData["EditError"] = "Please, correct all errors.";
     return PartialView("createPartial");
 }
Ejemplo n.º 6
0
 public ActionResult UpdatePartial(ItemWarehouseModel model)
 {
     if (ModelState.IsValid)
     {
         model.SOBId = SessionHelper.SOBId;
         try
         {
             ItemHelper.UpdateItemDetail(model);
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
         ViewData["EditError"] = "Please, correct all errors.";
     return PartialView("createPartial", ItemHelper.GetItemWarehouses());
 }
Ejemplo n.º 7
0
        public ActionResult AddNewPartial(ItemWarehouseModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    bool validated = false;
                    model.SOBId = SessionHelper.SOBId;
                    if (SessionHelper.Item != null)
                    {
                        model.Id = SessionHelper.Item.ItemWarehouses.Count() + 1;
                        validated = true;
                    }
                    else
                        model.Id = 1;

                    if (validated)
                        ItemHelper.InsertItemDetail(model);
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
                ViewData["EditError"] = "Please, correct all errors.";
            return PartialView("createPartial", ItemHelper.GetItemWarehouses());
        }