Example #1
0
        public List <PaymentTypeVM> GetAllPaymentTypes()
        {
            try
            {
                var paymentTypeData = unitOfWork.TblPaymentTypeRepository.Get().ToList();

                List <PaymentTypeVM> paymentTypeList = new List <PaymentTypeVM>();

                foreach (var paymentType in paymentTypeData)
                {
                    PaymentTypeVM paymentTypeVM = new PaymentTypeVM();
                    paymentTypeVM.PaymentTypeID   = paymentType.PaymentTypeID;
                    paymentTypeVM.PaymentTypeName = paymentType.PaymentType;
                    paymentTypeVM.Description     = paymentType.Description;
                    paymentTypeVM.CreatedBy       = paymentType.CreatedBy != null?Convert.ToInt32(paymentType.CreatedBy) : 0;

                    paymentTypeVM.CreatedDate = paymentType.CreatedDate != null?paymentType.CreatedDate.ToString() : string.Empty;

                    paymentTypeVM.ModifiedBy = paymentType.ModifiedBy != null?Convert.ToInt32(paymentType.ModifiedBy) : 0;

                    paymentTypeVM.ModifiedDate = paymentType.ModifiedDate != null?paymentType.ModifiedDate.ToString() : string.Empty;

                    paymentTypeList.Add(paymentTypeVM);
                }

                return(paymentTypeList);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Example #2
0
        public PaymentTypeVM GetPaymentTypeByID(int paymentTypeID)
        {
            try
            {
                var paymentTypeData = unitOfWork.TblPaymentTypeRepository.GetByID(paymentTypeID);

                PaymentTypeVM paymentTypeVM = new PaymentTypeVM();
                paymentTypeVM.PaymentTypeID   = paymentTypeData.PaymentTypeID;
                paymentTypeVM.PaymentTypeName = paymentTypeData.PaymentType;
                paymentTypeVM.Description     = paymentTypeData.Description;
                paymentTypeVM.CreatedBy       = paymentTypeData.CreatedBy != null?Convert.ToInt32(paymentTypeData.CreatedBy) : 0;

                paymentTypeVM.CreatedDate = paymentTypeData.CreatedDate != null?paymentTypeData.CreatedDate.ToString() : string.Empty;

                paymentTypeVM.ModifiedBy = paymentTypeData.ModifiedBy != null?Convert.ToInt32(paymentTypeData.ModifiedBy) : 0;

                paymentTypeVM.ModifiedDate = paymentTypeData.ModifiedDate != null?paymentTypeData.ModifiedDate.ToString() : string.Empty;

                return(paymentTypeVM);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Example #3
0
        public bool UpdatePaymentType(PaymentTypeVM paymentTypeVM)
        {
            using (var dbTransaction = unitOfWork.dbContext.Database.BeginTransaction())
            {
                try
                {
                    tblPaymentType paymentType = unitOfWork.TblPaymentTypeRepository.GetByID(paymentTypeVM.PaymentTypeID);
                    paymentType.PaymentType  = paymentTypeVM.PaymentTypeName;
                    paymentType.Description  = paymentTypeVM.Description;
                    paymentType.ModifiedDate = DateTime.Now;
                    paymentType.ModifiedBy   = paymentTypeVM.ModifiedBy;
                    unitOfWork.TblPaymentTypeRepository.Update(paymentType);
                    unitOfWork.Save();

                    //Complete the Transaction
                    dbTransaction.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    //Roll back the Transaction
                    dbTransaction.Rollback();
                    return(false);
                }
            }
        }
Example #4
0
        public ActionResult add_id_proof(PaymentTypeVM vmObj)
        {
            vmObj.CreatedBy   = 1;
            vmObj.CreatedDate = DateTime.Now;
            vmObj.UpdatedBy   = 1;
            vmObj.UpdatedDate = DateTime.Now;


            int isSaved = 0;

            if (ModelState.IsValid)
            {
                var result = Mapper.Map <PaymentType>(vmObj);

                result.IsActive = true;

                isSaved = _Manager.Add(result);
                if (isSaved > 0)
                {
                    status  = true;
                    message = "Succesfully Saved";
                }
                else
                {
                    status  = true;
                    message = "Error! Please try again.";
                }

                return(new JsonResult {
                    Data = new { status = status, message = message }
                });
            }

            else
            {
                status  = false;
                message = "PaymentType Allready Exsists !!!";
                return(new JsonResult {
                    Data = new { status = status, message = message }
                });
            }
        }
Example #5
0
        public IHttpActionResult UpdatePaymentType([FromBody] JObject data)
        {
            try
            {
                int    paymentTypeID   = !string.IsNullOrEmpty(data.SelectToken("PaymentTypeID").Value <string>()) ? Convert.ToInt32(data.SelectToken("PaymentTypeID").Value <string>()) : 0;
                string paymentTypeName = !string.IsNullOrEmpty(data.SelectToken("PaymentTypeName").Value <string>()) ? data.SelectToken("PaymentTypeName").Value <string>() : string.Empty;
                string description     = !string.IsNullOrEmpty(data.SelectToken("Description").Value <string>()) ? data.SelectToken("Description").Value <string>() : string.Empty;
                int    userID          = !string.IsNullOrEmpty(data.SelectToken("UserID").Value <string>()) ? Convert.ToInt32(data.SelectToken("UserID").Value <string>()) : 0;

                if (!managePaymentType.IsPaymentTypeAvailable(paymentTypeID, paymentTypeName))
                {
                    PaymentTypeVM paymentTypeVM = new PaymentTypeVM();
                    paymentTypeVM.PaymentTypeID   = paymentTypeID;
                    paymentTypeVM.PaymentTypeName = paymentTypeName;
                    paymentTypeVM.Description     = description;
                    paymentTypeVM.ModifiedBy      = userID;

                    bool status = managePaymentType.UpdatePaymentType(paymentTypeVM);

                    if (status)
                    {
                        return(Json(new { status = true, message = "Successfully Updated" }));
                    }
                    else
                    {
                        return(Json(new { status = false, message = "Update Failed" }));
                    }
                }
                else
                {
                    return(Json(new { status = false, message = "Payment Type Name already exists" }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { status = false, message = "Unknown error occurred" }));
            }
        }