public async Task <string> AddOperation(OperationSetup op)
        {
            var ent = op.ToOperation();
            await _operationRepository.AddOperation(ent.ToOperationEntity());

            return(ent.OperationId);
        }
Exemplo n.º 2
0
        public async ValueTask <ActionResult <AuthOutputModel> > CreateWithdrawTransactionStepOne([FromBody] TransactionInputModel transactionModel)
        {
            var checkingAccountId = await _repo.GetAccountById(transactionModel.AccountId);

            if (checkingAccountId.Data is null)
            {
                return(BadRequest("The account is not found"));
            }
            if (transactionModel.Amount <= 0)
            {
                return(BadRequest("The amount is missing"));
            }
            _authentication.GenerateTwoFactorAuthentication(transactionModel.AccountId);
            AuthOutputModel auth = new AuthOutputModel();
            var             tmp  = await _operation.AddOperation(_mapper.Map <OperationDto>(transactionModel));

            auth.Id = tmp.Data;
            auth.AuthenticationManualCode = _authentication.AuthenticationManualCode;
            return(auth);
        }
Exemplo n.º 3
0
        public async Task <IEnumerable <OperationReturnDataModel> > AddOperation()
        {
            try
            {
                OperationBodyModel operationBodyModel = new OperationBodyModel();
                var httpRequest = HttpContext.Current.Request;

                var operationType = Convert.ToInt32(httpRequest.Form["OperationType"]);
                var operationName = httpRequest.Form["OperationName"].ToString();
                var smvValue      = Convert.ToDecimal(httpRequest.Form["SmvValue"]);
                var machine       = httpRequest.Form["Machine"].ToString();

                var buyerId = Convert.ToInt32(httpRequest.Form["BuyerId"]);
                //var buyerCategoryId = Convert.ToInt32(httpRequest.Form["BuyerCatId"]);
                var buyerComponentId  = Convert.ToInt32(httpRequest.Form["ComponentId"]);
                var componentCatId    = Convert.ToInt32(httpRequest.Form["ComponentCatId"]);
                var componentSubCatId = Convert.ToInt32(httpRequest.Form["ComponentSubCatId"]);
                var isActive          = Convert.ToInt32(httpRequest.Form["IsActive"]);

                operationBodyModel.OperationType = operationType;
                operationBodyModel.OperationName = operationName;
                operationBodyModel.SmvValue      = smvValue;
                operationBodyModel.Machine       = machine;
                operationBodyModel.BuyerId       = buyerId;
                //operationBodyModel.BuyerCatId = buyerCategoryId;
                operationBodyModel.ComponentId       = buyerComponentId;
                operationBodyModel.ComponentCatId    = componentCatId;
                operationBodyModel.ComponentSubCatId = componentSubCatId;
                operationBodyModel.IsActive          = isActive;


                var ReturnDataModel = await _operationRepository.AddOperation(operationBodyModel);

                var data = (from c in ReturnDataModel
                            select c.NewOperationId).FirstOrDefault();


                if (ReturnDataModel.ToList().Count() > 0)
                {
                    if (httpRequest.Files.Count > 0)
                    {
                        foreach (string file in httpRequest.Files)
                        {
                            var postedFile = httpRequest.Files[file];
                            if (postedFile != null && postedFile.ContentLength > 0)
                            {
                                IList <string> AllowedFileExtensions = new List <string> {
                                    ".pdf"                                                     /*,".flv",".avi", ".mp4", ".mpg", ".wmv"*/
                                };
                                var ext       = postedFile.FileName.Substring(postedFile.FileName.LastIndexOf('.'));
                                var extension = ext.ToLower();
                                if (AllowedFileExtensions.Contains(extension))
                                {
                                    //if(extension==".pdf")
                                    //{
                                    var filePath = HttpContext.Current.Server.MapPath("~/Files/GSD/" + data + extension);
                                    postedFile.SaveAs(filePath);
                                    //}
                                    //else
                                    //{
                                    //    var filePath = HttpContext.Current.Server.MapPath("~/Files/OperationVideos/" + OperationReturnDataModel + extension);
                                    //    postedFile.SaveAs(filePath);
                                    //}
                                }
                            }
                        }
                    }
                }
                return(ReturnDataModel);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }