public Int32 UpdateTransactionType(TransactionTypeObject transactionType)
        {
            try
            {
                if (transactionType == null)
                {
                    return(-2);
                }

                if (_repository.Count(m => m.Name.Trim().ToLower() == transactionType.Name.Trim().ToLower() && (m.TransactionTypeId != transactionType.TransactionTypeId)) > 0)
                {
                    return(-3);
                }

                var transactionTypeEntity = ModelCrossMapper.Map <TransactionTypeObject, TransactionType>(transactionType);
                if (transactionTypeEntity == null || transactionTypeEntity.TransactionTypeId < 1)
                {
                    return(-2);
                }
                _repository.Update(transactionTypeEntity);
                _uoWork.SaveChanges();
                return(5);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
                return(-2);
            }
        }
 public long AddTransactionType(TransactionTypeObject transactionType)
 {
     try
     {
         if (transactionType == null)
         {
             return(-2);
         }
         if (_repository.Count(m => m.Name.Trim().ToLower() == transactionType.Name.Trim().ToLower()) > 0)
         {
             return(-3);
         }
         var transactionTypeEntity = ModelCrossMapper.Map <TransactionTypeObject, TransactionType>(transactionType);
         if (transactionTypeEntity == null || string.IsNullOrEmpty(transactionTypeEntity.Name))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(transactionTypeEntity);
         _uoWork.SaveChanges();
         return(returnStatus.TransactionTypeId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
        private GenericValidator ValidateTransactionType(TransactionTypeObject transactionType)
        {
            var gVal = new GenericValidator();

            if (transactionType == null)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Fatal_Error;
                return(gVal);
            }
            if (string.IsNullOrEmpty(transactionType.Name))
            {
                gVal.Code  = -1;
                gVal.Error = "Please provide Transaction Type name.";
                return(gVal);
            }
            if (string.IsNullOrEmpty(transactionType.Action))
            {
                gVal.Code  = -1;
                gVal.Error = "Please provide the Action for this Transaction Type.";
                return(gVal);
            }
            gVal.Code  = 5;
            gVal.Error = "";
            return(gVal);
        }
        public ActionResult EditTransactionType(TransactionTypeObject transactionType)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateTransactionType(transactionType);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    if (Session["_transactionType"] == null)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var oldTransactionType = Session["_transactionType"] as TransactionTypeObject;
                    if (oldTransactionType == null || oldTransactionType.TransactionTypeId < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    oldTransactionType.Name   = transactionType.Name.Trim();
                    oldTransactionType.Action = transactionType.Action.Trim();

                    if (!string.IsNullOrEmpty(transactionType.Description))
                    {
                        oldTransactionType.Description = transactionType.Description;
                    }

                    var k = new TransactionTypeServices().UpdateTransactionType(oldTransactionType);
                    if (k < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = k == -3 ? "Transaction Type information already exists" : "Transaction Type information could not be updated. Please try again";
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.Code = 5;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -1;
                gVal.Error = message_Feedback.Model_State_Error;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Пример #5
0
 public int UpdateTransactionType(TransactionTypeObject transactionType)
 {
     try
     {
         return(_transactionTypeRepository.UpdateTransactionType(transactionType));
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(-2);
     }
 }
        public ActionResult AddTransactionType(TransactionTypeObject transactionType)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateTransactionType(transactionType);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var k = new TransactionTypeServices().AddTransactionType(transactionType);
                    if (k < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = k == -3 ? "Transaction Type information already exists" : "Transaction Type information could not be added. Please try again";
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.Code = 5;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -1;
                gVal.Error = message_Feedback.Model_State_Error;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }