Beispiel #1
0
        public ActionResult Update(MPacketItemCat viewModel, FormCollection formCollection)
        {
            UpdateNumericData(viewModel, formCollection);
            MPacketItemCat mPacketItemCatToUpdate = _mPacketItemCatRepository.Get(viewModel.Id);

            mPacketItemCatToUpdate.ItemCatId = _mItemCatRepository.Get(formCollection["ItemCatId"]);
            //mPacketItemCatToUpdate.PacketId = _mPacketRepository.Get(formCollection["PacketId"]);
            TransferFormValuesTo(mPacketItemCatToUpdate, viewModel);
            mPacketItemCatToUpdate.ModifiedDate = DateTime.Now;
            mPacketItemCatToUpdate.ModifiedBy   = User.Identity.Name;
            mPacketItemCatToUpdate.DataStatus   = EnumDataStatus.Updated.ToString();

            _mPacketItemCatRepository.Update(mPacketItemCatToUpdate);

            try
            {
                _mPacketItemCatRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mPacketItemCatRepository.DbContext.RollbackTransaction();

                return(Content(e.GetBaseException().Message));
            }

            return(Content("success"));
        }
Beispiel #2
0
        public ActionResult PopupInsert(MPacketItemCat viewModel, FormCollection formCollection, string packetId)
        {
            UpdateNumericData(viewModel, formCollection);
            MPacketItemCat mPacketItemCatToInsert = new MPacketItemCat();

            TransferFormValuesTo(mPacketItemCatToInsert, viewModel);
            mPacketItemCatToInsert.ItemCatId = _mItemCatRepository.Get(formCollection["ItemCatId"]);
            mPacketItemCatToInsert.PacketId  = _mPacketRepository.Get(packetId);

            mPacketItemCatToInsert.SetAssignedIdTo(Guid.NewGuid().ToString());
            mPacketItemCatToInsert.CreatedDate = DateTime.Now;
            mPacketItemCatToInsert.CreatedBy   = User.Identity.Name;
            mPacketItemCatToInsert.DataStatus  = EnumDataStatus.New.ToString();

            //IList<MItemUom> listItemUom = new List<MItemUom>();

            //mItemToInsert.ItemUoms = listItemUom;

            _mPacketItemCatRepository.Save(mPacketItemCatToInsert);

            try
            {
                _mPacketItemCatRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mPacketItemCatRepository.DbContext.RollbackTransaction();

                //throw e.GetBaseException();
                return(Content(e.GetBaseException().Message));
            }

            return(Content("success"));
        }
Beispiel #3
0
 public virtual ActionResult Get(string id)
 {
     if (!string.IsNullOrEmpty(id))
     {
         MPacketItemCat mItem = _mPacketItemCatRepository.Get(id);
     }
     return(Content("0"));
 }
Beispiel #4
0
 private void UpdateNumericData(MPacketItemCat viewModel, FormCollection formCollection)
 {
     if (!string.IsNullOrEmpty(formCollection["ItemCatQty"]))
     {
         string ItemCatQty = formCollection["ItemCatQty"].Replace(",", "");
         viewModel.ItemCatQty = Convert.ToDecimal(ItemCatQty);
     }
     else
     {
         viewModel.ItemCatQty = null;
     }
 }
Beispiel #5
0
        public virtual ActionResult GetList()
        {
            var            items = _mPacketItemCatRepository.GetAll();
            StringBuilder  sb    = new StringBuilder();
            MPacketItemCat mItem = new MPacketItemCat();

            sb.AppendFormat("{0}:{1};", string.Empty, "-Pilih Paket Item Category-");
            for (int i = 0; i < items.Count; i++)
            {
                mItem = items[i];
                sb.AppendFormat("{0}:{1}", mItem.Id, mItem.PacketItemCatDesc);
                if (i < items.Count - 1)
                {
                    sb.Append(";");
                }
            }
            return(Content(sb.ToString()));
        }
Beispiel #6
0
        public ActionResult Delete(MPacketItemCat viewModel, FormCollection formCollection)
        {
            MPacketItemCat mPacketItemCatToDelete = _mPacketItemCatRepository.Get(viewModel.Id);

            if (mPacketItemCatToDelete != null)
            {
                _mPacketItemCatRepository.Delete(mPacketItemCatToDelete);
            }

            try
            {
                _mPacketItemCatRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mPacketItemCatRepository.DbContext.RollbackTransaction();

                return(Content(e.GetBaseException().Message));
            }

            return(Content("success"));
        }
Beispiel #7
0
 private void TransferFormValuesTo(MPacketItemCat mPacketItemCatToUpdate, MPacketItemCat mPacketItemCatFromForm)
 {
     mPacketItemCatToUpdate.ItemCatQty          = mPacketItemCatFromForm.ItemCatQty;
     mPacketItemCatToUpdate.PacketItemCatStatus = mPacketItemCatFromForm.PacketItemCatStatus;
     mPacketItemCatToUpdate.PacketItemCatDesc   = mPacketItemCatFromForm.PacketItemCatDesc;
 }