// [TypeFilter(typeof(AuthorizeAction), Arguments = new object[] { "Read" })]
        public IActionResult SummaryView()
        {
            TransactionTypeViewModel model = new TransactionTypeViewModel();

            InitAccessModel(model);
            return(View(model));
        }
 public ActionResult AddEditTransactionType(long?id, TransactionTypeViewModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             bool            isNew           = !id.HasValue;
             TransactionType transactionType = isNew ? new TransactionType
             {
                 //AddedDate = DateTime.UtcNow
             } : transactionTypeRepository.GetTransactionType(id.Value);
             transactionType.typeName = model.typeName;
             if (isNew)
             {
                 transactionTypeRepository.SaveTransactionType(transactionType);
             }
             else
             {
                 transactionTypeRepository.UpdateTransactionType(transactionType);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(RedirectToAction("Index"));
 }
Exemplo n.º 3
0
 public async Task <TransactionTypeViewModel> EncodeTransactionTypeId(TransactionTypeViewModel transactionType)
 {
     return(await Task.Run(() =>
     {
         transactionType.TransactionTypeId = GuidEncoder.Encode(transactionType.TransactionTypeId);
         return transactionType;
     }));
 }
        public IActionResult DeleteTransactionType(long id)
        {
            TransactionType          transactionType = transactionTypeRepository.GetTransactionType(id);
            TransactionTypeViewModel model           = new TransactionTypeViewModel
            {
                typeName = $"{transactionType.typeName}"
            };

            return(PartialView("~/Views/TransactionTypes/_DeleteTransactionType.cshtml", model));
        }
        public IActionResult Put([FromBody] TransactionTypeViewModel TransactionTypeViewModel)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(Response(TransactionTypeViewModel));
            }

            _TransactionTypeAppService.Update(TransactionTypeViewModel);

            return(Response(TransactionTypeViewModel));
        }
 public IActionResult Index(TransactionTypeViewModel model)
 {
     if (ModelState.IsValid)
     {
         return(Json(_interface.AddUpdate(model)));
     }
     else
     {
         JsonResponse resp = new JsonResponse();
         resp.Message = Constants.ControllerMessage.All_Fields_Mandatory;
         return(Json(resp));
     }
 }
        public IActionResult AddEditTransactionType(long?id)
        {
            TransactionTypeViewModel model = new TransactionTypeViewModel();

            if (id.HasValue)
            {
                TransactionType transactionType = transactionTypeRepository.GetTransactionType(id.Value); if (transactionType != null)
                {
                    model.typeId   = transactionType.typeId;
                    model.typeName = transactionType.typeName;
                }
            }
            return(PartialView("~/Views/TransactionTypes/_AddEditTransactionType.cshtml", model));
        }
        private List <TransactionViewModel> CreateListTransactionViewModel(List <IFormFile> files)
        {
            var transactions = new List <TransactionViewModel>();

            foreach (var file in files)
            {
                using (var stream = new StreamReader(file.OpenReadStream()))
                {
                    string line       = "";
                    string lineValues = "";
                    int    count      = 0;
                    while (!stream.EndOfStream || line.Contains("</STMTTRN>"))
                    {
                        line = stream.ReadLine();
                        if (line.Contains("<TRNTYPE>") || line.Contains("<DTPOSTED>") || line.Contains("<TRNAMT>") || line.Contains("<MEMO>"))
                        {
                            lineValues += line.Split('>')[1] + ",";
                            count++;
                        }
                        if (count == 4)
                        {
                            var arrayValues = lineValues.Split(',');
                            TransactionTypeViewModel typeT = 0;
                            if (arrayValues[0].ToLower().Equals("debit"))
                            {
                                typeT = TransactionTypeViewModel.Credit;
                            }

                            if (arrayValues[0].ToLower().Equals("credit"))
                            {
                                typeT = TransactionTypeViewModel.Debit;
                            }

                            transactions.Add(new TransactionViewModel()
                            {
                                TRNTYPE  = typeT,
                                DTPOSTED = DateTime.ParseExact(arrayValues[1].Substring(0, 8), "yyyyMMdd", null),
                                TRNAMT   = arrayValues[2],
                                MEMO     = arrayValues[3].ToString(CultureInfo.CurrentCulture)
                            });
                            count      = 0;
                            lineValues = "";
                        }
                    }
                }
            }

            return(transactions);
        }
        // [TypeFilter(typeof(AuthorizeAction), Arguments = new object[] { "Write" })]
        public IActionResult Index()
        {
            TransactionTypeViewModel model = new TransactionTypeViewModel();

            InitAccessModel(model);
            model.TransactionNatureList = new List <SelectListItem>()
            {
                new SelectListItem {
                    Text = "Sell", Value = "S"
                },
                new SelectListItem {
                    Text = "Buy", Value = "B"
                }
            };
            return(View(model));
        }
        // [TypeFilter(typeof(AuthorizeAction), Arguments = new object[] { "Write" })]
        public IActionResult Update(long ID)
        {
            TransactionTypeViewModel model = new TransactionTypeViewModel();

            InitAccessModel(model);
            model.transactionTypes = _interface.GetTransactionType(ID);
            if (model.transactionTypes != null)
            {
                model.TransactionNatureList = new List <SelectListItem>()
                {
                    new SelectListItem {
                        Text = "Sell", Value = "S"
                    },
                    new SelectListItem {
                        Text = "Buy", Value = "B"
                    }
                };
                return(View("Index", model));
            }
            else
            {
                return(View("SummaryView", model));
            }
        }
        public JsonResponse AddUpdate(TransactionTypeViewModel model)
        {
            try
            {
                SqlParameter[] param = new SqlParameter[5];
                param[0] = new SqlParameter("@ID", model.transactionTypes.ID);
                param[1] = new SqlParameter("@TransactionType", model.transactionTypes.Type);
                param[2] = new SqlParameter("@TransactionNature", model.transactionTypes.Nature);
                param[3] = new SqlParameter("@UserID", GetUserID());
                param[4] = new SqlParameter("@IsActive", model.transactionTypes.IsActive);
                int id = new ADODataFunction().ExecuteNonQuery(Constants.Procedures.AddUpdateTransactionType, param, CommandType.StoredProcedure);
                //  If i != 0 means it affect one data So the data was Inserted.
                if (id != 0)
                {
                    if (model.transactionTypes.ID > 0)
                    {
                        resp.Message = Constants.Service.Data_Update_success;
                    }
                    else
                    {
                        resp.Message = Constants.Service.Data_insert_success;
                    }
                    resp.Status = Constants.ResponseStatus.Success;
                }
                else
                {
                    resp.Message = Constants.Service.Common_message;
                }
            }
            catch (Exception ex)
            {
                resp.Message = Constants.Service.Common_message;
            }

            return(resp);
        }
Exemplo n.º 12
0
        public void Update(TransactionTypeViewModel TransactionTypeViewModel)
        {
            var updateCommand = _mapper.Map <UpdateTransactionTypeCommand>(TransactionTypeViewModel);

            Bus.SendCommand(updateCommand);
        }
Exemplo n.º 13
0
        public void Register(TransactionTypeViewModel TransactionTypeViewModel)
        {
            var registerCommand = _mapper.Map <RegisterNewTransactionTypeCommand>(TransactionTypeViewModel);

            Bus.SendCommand(registerCommand);
        }