Пример #1
0
        public ActionResult Insert(MActionCat viewModel, FormCollection formCollection)
        {
            MActionCat mItemCatToInsert = new MActionCat();

            TransferFormValuesTo(mItemCatToInsert, viewModel);
            mItemCatToInsert.SetAssignedIdTo(viewModel.Id);
            mItemCatToInsert.CreatedDate = DateTime.Now;
            mItemCatToInsert.CreatedBy   = User.Identity.Name;
            mItemCatToInsert.DataStatus  = EnumDataStatus.New.ToString();
            _mActionCatRepository.Save(mItemCatToInsert);

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

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

            return(Content("success"));
        }
Пример #2
0
        public ActionResult Delete(MActionCat viewModel, FormCollection formCollection)
        {
            MActionCat mItemCatToDelete = _mActionCatRepository.Get(viewModel.Id);

            if (mItemCatToDelete != null)
            {
                _mActionCatRepository.Delete(mItemCatToDelete);
            }

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

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

            return(Content("success"));
        }
Пример #3
0
        public ActionResult Update(MActionCat viewModel, FormCollection formCollection)
        {
            MActionCat mItemCatToUpdate = _mActionCatRepository.Get(viewModel.Id);

            TransferFormValuesTo(mItemCatToUpdate, viewModel);
            mItemCatToUpdate.ModifiedDate = DateTime.Now;
            mItemCatToUpdate.ModifiedBy   = User.Identity.Name;
            mItemCatToUpdate.DataStatus   = EnumDataStatus.Updated.ToString();
            _mActionCatRepository.Update(mItemCatToUpdate);

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

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

            return(Content("success"));
        }
Пример #4
0
 private void TransferFormValuesTo(MActionCat mItemCatToUpdate, MActionCat mItemCatFromForm)
 {
     mItemCatToUpdate.ActionCatName = mItemCatFromForm.ActionCatName;
     mItemCatToUpdate.ActionCatDesc = mItemCatFromForm.ActionCatDesc;
 }