示例#1
0
        // TODO
        public ResponseDTO CreateMember(RequestDTO<McMember> request)
        {
            ResponseDTO response = new ResponseDTO();
            McMember newMember = request.Inputs.First();

            if (newMember != null)
            {
                // New Member Validation
                if (!string.IsNullOrWhiteSpace(newMember.MemId)
                   && !string.IsNullOrWhiteSpace(newMember.FirstName)
                   && !string.IsNullOrWhiteSpace(newMember.LastName)
                   && newMember.DOB.HasValue)
                {
                    UnitOfWork.MemberRepo.Add(newMember);
                    UnitOfWork.Commit();

                    response.Results = ResponseResults.Success;
                }
                else
                {
                    response = ResponseUtility.CreateErrorResponse(ResponseResults.FailAndNoRetry, MemberExceptions.AddValidationFail);
                }
            }
            else
            {
                response = ResponseUtility.CreateErrorResponse(ResponseResults.FailAndNoRetry, MemberExceptions.InvalidMember);
            }

            return response;
        }
 public ClienteService()
 {
     // Inicializamos o Response
     _resposta = new ResponseDTO<ClienteModel>();
     // Inicializamos o cronometro
     _cronometro = new Stopwatch();
 }
示例#3
0
        public async Task <List <NewsModel> > GetNews(int count, int page)
        {
            try
            {
                var url = BaseUrl + $"news/get?count={count}&page={page}";
                ResponseDTO <NewsModel> result = await restClient.MakeRequestAsync <NewsModel>(url, HttpMethod.Get);

                if (!result.IsSuccess)
                {
                    throw new Exception();
                }

                return(await SortNewsAsync(result.Content));
            }
            catch (Exception)
            {
                throw new NetworkErrorException("Не удалсь обновить список новостей.");
            }
        }
示例#4
0
        public void TokenCreated()
        {
            ResponseDTO <LoginDTO> responseDTO = new ResponseDTO <LoginDTO>();

            responseDTO.Data = new LoginDTO()
            {
                UserName = "******",
                Type     = "Enable"
            };

            GetLoginToken disabledUser = new GetLoginToken()
            {
                responseDTO = responseDTO
            };

            var response = (LoginResponseDTO)disabledUser.Execute().Result;

            Assert.True(response.isSuccessful);
        }
示例#5
0
        public void UserNotEnable()
        {
            ResponseDTO <LoginDTO> responseDTO = new ResponseDTO <LoginDTO>();

            responseDTO.Data = new LoginDTO()
            {
                UserName = "******",
                Type     = "Disable"
            };

            GetLoginToken disabledUser = new GetLoginToken()
            {
                responseDTO = responseDTO
            };

            var response = (LoginResponseDTO)disabledUser.Execute().Result;

            Assert.False(response.isSuccessful);
        }
        public async Task <IActionResult> AddModerator([FromBody] ModeratorDTO addModeratorDTO)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest());
                }

                ResponseDTO check = await moderatorsCrudService.CheckModeratorExistForAdd(addModeratorDTO.Login);

                if (check.Status == false)
                {
                    return(Conflict(check));
                }

                check = await adminsCrudService.CheckAdminExistForAdd(addModeratorDTO.Login);

                if (check.Status == false)
                {
                    return(Conflict(check));
                }

                Admin admin = await adminsCrudService.CheckAdminExist(addModeratorDTO.AdminId);

                ResponseDTO answer = await moderatorsCrudService.AddModerator(admin, addModeratorDTO);

                logger.LogInformation($"Модератор: {addModeratorDTO.Login}, был добавлен Админом {admin.Login}");

                Moderator moderator = await moderatorsCrudService.CheckModeratorExist(answer.ResponseData.Id);

                moderator = moderator.ModeratorWithoutPassword();
                return(Ok(new { answer, moderator }));
            }
            catch (Exception ex)
            {
                logger.LogError(ex.Message);
                return(StatusCode(500, new ResponseDTO()
                {
                    Status = false
                }));
            }
        }
        //Post api/Customer

        public IHttpActionResult Post([FromBody] DCAddressDTO dCAddressDTO)
        {
            try
            {
                if (dCAddressDTO == null)
                {
                    Ok(ResponseHelper.CreateResponseDTOForException("Argument Null"));
                }
                //Create New Distribution Center
                ResponseDTO responseDTO = _dCAddressService.AddDCAddress(dCAddressDTO);

                return(Ok(responseDTO));
            }
            catch (PlatformModuleException ex)
            {
                //Write Log Here
                return(Ok(ResponseHelper.CreateResponseDTOForException(ex.Message)));
            }
        }
示例#8
0
        public BusinessActivityService(string terminalId, ref ResponseDTO res)
        {
            var host       = eCatConfig.Host();
            var registered = eCatConfig.GetValue("Registered");

            if (registered == null || registered == "0")
            {
                Registrar(terminalId);
            }
            else
            {
                Console.WriteLine("Cajero registrado");
            }

            var user = eCatConfig.GetValue("ATMUser");
            var pass = eCatConfig.GetValue("ATMPass");

            _service = new BankService(host, user, pass, true, ref res);
        }
        public async Task <JsonResult> CreateOrder(string address, string remark, int documentType)
        {
            UserDTO             u         = (UserDTO)Session["User"];
            List <OrderCartDTO> orderList = new List <OrderCartDTO>();

            if (System.Web.HttpContext.Current.Session["Cart"] == null)
            {
                System.Web.HttpContext.Current.Session["Cart"] = orderList;
            }
            orderList = (List <OrderCartDTO>)System.Web.HttpContext.Current.Session["Cart"];
            var newOrder       = new OrderDTO();
            var newOrderDetail = new List <OrderDetailDTO>();

            newOrder.Date           = DateTime.Now;
            newOrder.Address        = address;
            newOrder.Remark         = remark;
            newOrder.UserId         = u.UserId;
            newOrder.DocumentTypeId = documentType;
            var nod = new OrderDetailDTO();

            for (var i = 0; i < orderList.Count; i++)
            {
                nod.ProductId = orderList[i].Product.ProductId;
                nod.Price     = orderList[i].Product.Price.Value;
                nod.Quantity  = orderList[i].Quantity;
                newOrderDetail.Add(nod);
            }
            newOrder.OrderDetails = newOrderDetail;
            var                 final       = new ResponseDTO();
            HttpClient          client      = new HttpClient();
            var                 jsonRequest = JsonConvert.SerializeObject(newOrder);
            var                 content     = new StringContent(jsonRequest, Encoding.UTF8, "text/json");
            HttpResponseMessage response    = await client.PostAsync(restServiceURL + "OrderClient", content);

            if (response.IsSuccessStatusCode)
            {
                final = await response.Content.ReadAsAsync <ResponseDTO>();

                System.Web.HttpContext.Current.Session["Cart"] = new List <OrderCartDTO>();
            }

            return(Json(final));
        }
示例#10
0
        public async Task <IActionResult> Add([FromBody] ProviderDTO model)
        {
            // Validate
            if (string.IsNullOrEmpty(model.Name))
            {
                return(Ok(ResponseDTO.BadRequest("Not enough information to create.")));
            }

            var provide = new Provider
            {
                Name        = model.Name,
                Email       = model.Email,
                Address     = model.Address,
                PhoneNumber = model.PhoneNumber,
                TIN         = model.TIN
            };

            return(await this._AddItem(provide));
        }
        public async Task <ResponseDTO> ValidateCellphoneAndUser(string cellphoneNumber, int?userid)
        {
            Expression <Func <DeviceDTO, bool> > queryFilter = p => true;
            var result = "";

            if (userid.HasValue)
            {
                queryFilter = queryFilter.And(p => p.CellphoneNumber != cellphoneNumber.Trim());
                queryFilter = queryFilter.And(p => p.AssignedAmigoTenantTUserId == userid);
                var device = await _deviceDataAccess.FirstOrDefaultAsync(queryFilter);

                if (device != null)
                {
                    result = "The cellphone has another user associated or the user is assigned to another device";
                }
                else
                {
                    Expression <Func <DeviceDTO, bool> > queryFilter1 = p => true;
                    queryFilter1 = queryFilter1.And(p => p.CellphoneNumber != cellphoneNumber.Trim());
                    queryFilter1 = queryFilter1.And(p => p.AssignedAmigoTenantTUserId == userid);
                    device       = await _deviceDataAccess.FirstOrDefaultAsync(queryFilter1);

                    if (device != null)
                    {
                        result = "The user has another device associated";
                    }
                }
            }

            var response = new ResponseDTO()
            {
                IsValid  = string.IsNullOrEmpty(result),
                Messages = new List <ApplicationMessage>()
            };

            response.Messages.Add(new ApplicationMessage()
            {
                Key     = string.IsNullOrEmpty(result)? "Ok":"Error",
                Message = result
            });

            return(response);
        }
 public ResponseDTO <bool> AddLot(Guid ownerid, string lotname, string address, double cost, UserAccount useraccount, HttpPostedFile spotfile, HttpPostedFile mapfile)
 {
     try
     {
         Lot newLot = new Lot()
         {
             LotId   = Guid.NewGuid(),
             OwnerId = ownerid,
             LotName = lotname,
             Address = address,
             Cost    = cost,
             //UserAccount = useraccount
             MapFilePath = useraccount.Username + "_" + lotname + "_" + Guid.NewGuid().ToString() + Path.GetExtension(mapfile.FileName)
         };
         newLot.Spots = ParseSpotsFromFile(newLot.LotId, newLot.LotName, spotfile);
         ResponseDTO <bool> response = _lotGateway.AddLot(newLot, newLot.Spots);
         if (response.Data == true)
         {
             ResponseDTO <bool> saveMap = _lotGateway.AddMapFile(mapfile, newLot.MapFilePath);
             if (saveMap.Data == false)
             {
                 return(saveMap);
             }
         }
         return(response);
     }
     catch (ArgumentException)
     {
         return(new ResponseDTO <Boolean>()
         {
             Data = false,
             Error = "[LOT MANAGEMENT SERVICE] Improperly formatted file."
         });
     }
     catch (Exception)
     {
         return(new ResponseDTO <Boolean>()
         {
             Data = false,
             Error = "[LOT MANAGEMENT SERVICE] Could not add lot."
         });
     }
 }
示例#13
0
        public ListaMesaOutDTO ListarMesa(int estadoMesaId)
        {
            ListaMesaOutDTO response = new ListaMesaOutDTO();
            MesaOutDTO      mesa     = new MesaOutDTO();

            response.listaMesas = new List <MesaOutDTO>();
            _IResultlSetHelper.setDataSource(conectionString);
            var responseDTO = new ResponseDTO();

            string        packageName   = "pkg_iteracion_2";
            string        procedureName = "LISTAR_MESAS";
            List <string> inParam       = new List <string>();
            List <string> outParam      = new List <string>();
            List <string> result        = new List <string>();

            inParam.Add(estadoMesaId.ToString());
            outParam.Add("o_cursor");
            outParam.Add("o_error");

            var oReader = _IResultlSetHelper.executePackage(packageName, procedureName, inParam, outParam, "o_cursor");

            if (oReader.Rows.Count > 0)
            {
                foreach (DataRow row in oReader.Rows)
                {
                    mesa.mesaId           = int.Parse(row[0].ToString());
                    mesa.nombre           = row[1].ToString();
                    mesa.cantidadPersonas = int.Parse(row[2].ToString());
                    mesa.estadoMesa       = row[3].ToString();
                    mesa.ubicacionMesa    = row[4].ToString();
                    response.listaMesas.Add(mesa);
                }
                response.code    = 0;
                response.message = "OK";
            }
            else
            {
                response.code    = 999;
                response.message = String.Concat("NoOk - ", result[2].ToString());
            }

            return(response);
        }
示例#14
0
        public ResponseDTO NextDayActiviity(RequestNextDayActivity request)
        {
            ResponseDTO resp = new ResponseDTO();

            using (ProjectManagementBLL objProjectManagementBLL = new ProjectManagementBLL())
            {
                try
                {
                    APICredentialsBLL credentialsBLL = new APICredentialsBLL();
                    credentialsBLL.UserName = request.APICredentials.APIUserName;
                    credentialsBLL.Password = request.APICredentials.APIPassword;
                    if (!new CommonMethods().ValidateRequest(credentialsBLL))
                    {
                        resp.ResponseCode    = ResponseCodes.Failed;
                        resp.ResponseMessage = ResponseMessages.InvalidCredentials;
                    }
                    else if (request.UserID == 0 || string.IsNullOrEmpty(request.NextDayActivity))
                    {
                        resp.ResponseCode    = ResponseCodes.Failed;
                        resp.ResponseMessage = ResponseMessages.InvalidData;
                    }
                    else
                    {
                        if (new ActivityBLL().UpdateNextDayActivity(objProjectManagementBLL, request.UserID, request.NextDayActivity))
                        {
                            resp.ResponseCode    = ResponseCodes.Success;
                            resp.ResponseMessage = ResponseMessages.Success;
                        }
                        else
                        {
                            resp.ResponseCode    = ResponseCodes.Failed;
                            resp.ResponseMessage = ResponseMessages.Failed;
                        }
                    }
                }
                catch (Exception ex)
                {
                    resp.ResponseCode    = ResponseCodes.Failed;
                    resp.ResponseMessage = ex.Message;
                }
            }
            return(resp);
        }
示例#15
0
        public IResponseDTO NewSaveAdvertisementUpdate([FromForm] AdvertisementImageUpdateVM AdvertisementUpdateVM)
        {
            ResponseDTO res;

            try
            {
                if (AdvertisementUpdateVM.Image != null)
                {
                    var logoUrl = Hlper.UploadHelper.SaveFile(AdvertisementUpdateVM.Image, "AdsImage");
                    AdvertisementUpdateVM.AdsImage = logoUrl;
                }
                if (AdvertisementUpdateVM.Video != null)
                {
                    var VideoUrl = Hlper.UploadHelper.SaveFile(AdvertisementUpdateVM.Video, "AdsVideo");
                    AdvertisementUpdateVM.AdsVideo = VideoUrl;
                }
                return(_AdvertisementUpdateServices.PostAdvertisementUpdate(new AdvertisementUpdateVM()
                {
                    AdsUpdateId = Guid.NewGuid(),
                    AdsText = AdvertisementUpdateVM.AdsText,
                    AdsImage = AdvertisementUpdateVM.AdsImage,
                    AdsType = AdvertisementUpdateVM.AdsType,
                    AdsVideo = AdvertisementUpdateVM.AdsVideo,
                    Available = AdvertisementUpdateVM.Available,
                    CityId = AdvertisementUpdateVM.CityId,
                    CreationDate = AdvertisementUpdateVM.CreationDate,
                    EndDate = AdvertisementUpdateVM.EndDate,
                    Special = AdvertisementUpdateVM.Special,
                    StartDate = AdvertisementUpdateVM.StartDate,
                    AdsId = AdvertisementUpdateVM.AdsId,
                }));
            }
            catch (Exception ex)
            {
                res = new ResponseDTO()
                {
                    IsPassed = false,
                    Message  = "Error in UploadMarketLog " + ex.Message,
                    Data     = null,
                };
            }
            return(res);
        }
        /// <summary>
        /// Execute UserCredentialTransformer
        /// Take UserCredential and turns into LoginDTO
        /// </summary>
        /// <returns>LoginDTO</returns>
        public Outcome Execute()
        {
            var response = new Outcome();

            ResponseDTO <LoginDTO> validResponse = new ResponseDTO <LoginDTO>();

            validResponse.Messages = new List <string>();
            // Returns error if user credentials are null
            if (userCredential == null)
            {
                validResponse.IsSuccessful = false;
                validResponse.Messages.Add(AccountConstants.REGISTRATION_INVALID);

                response.Result = validResponse;
                return(response);
            }
            var validator = new UserCredValidator();
            var results   = validator.Validate(userCredential);

            IList <ValidationFailure> failures = results.Errors;

            // Returns any error messages if there was any when validating
            if (failures.Any())
            {
                foreach (ValidationFailure failure in failures)
                {
                    validResponse.Messages.Add(failure.ErrorMessage);
                }
                validResponse.IsSuccessful = false;
                response.Result            = validResponse;
                return(response);
            }

            validResponse.Data = new LoginDTO()
            {
                UserName = userCredential.Username,
                Password = userCredential.Password
            };
            validResponse.IsSuccessful = true;
            response.Result            = validResponse;

            return(response);
        }
示例#17
0
        public async Task <ResponseDTO <bool> > SendTextMessageAsync(TextMessageRequest request, Guid roomId, Guid userId)
        {
            var response = new ResponseDTO <bool>();
            var room     = await _context.Rooms.FirstOrDefaultAsync(r => r.Id == roomId);

            if (room == null)
            {
                response.Error = new Error(404, "Room not found");
                return(response);
            }
            if (!room.Participants.Select(p => p.UserId).Contains(userId))
            {
                response.Error = new Error(409, "You can't send message here, because you are not participant");
                return(response);
            }

            var message = new MessageEntity()
            {
                Id          = Guid.NewGuid(),
                SenderId    = userId,
                RoomId      = room.Id,
                Content     = request.Content,
                Type        = MessageTypes.Text,
                SendingTime = DateTime.UtcNow
            };

            await _context.Messages.AddAsync(message);

            await _context.SaveChangesAsync();

            var socketDTO = new SocketResponseDTO <MessageDTO>
            {
                Type = SocketMessageTypes.NewMessage, Model = new MessageDTO(message)
            };

            foreach (var participantId in room.Participants.Select(p => p.UserId))
            {
                await _chatHandler.SendMessageByUserId(participantId, socketDTO);
            }

            response.Data = true;
            return(response);
        }
        public async Task <IActionResult> Login(CustomerLoginDto dto)
        {
            var customer = await _repository.Login(dto.Username, dto.Password);

            if (customer == null)
            {
                return(BadRequest(ResponseDTO.Unauthorized()));
            }

            var claims = new[]
            {
                new Claim("sub", customer.Username)
            };

            var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config.GetSection("AppSettings:Token").Value));

            var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha512Signature);

            var tokenDescriptor = new SecurityTokenDescriptor
            {
                Subject            = new ClaimsIdentity(claims),
                Expires            = DateTime.Now.AddDays(1),
                SigningCredentials = creds,
            };

            var tokenHandler = new JwtSecurityTokenHandler();

            var token       = tokenHandler.CreateToken(tokenDescriptor);
            var tokenString = tokenHandler.WriteToken(token);

            var data = new ResponseLoginDto
            {
                id              = customer.Id,
                name            = customer.Name,
                dateOfBirth     = customer.DateOfBirth,
                email           = customer.Email,
                phoneNumber     = customer.PhoneNumber,
                gender          = customer.Gender,
                authorizedToken = tokenString
            };

            return(Ok(new ResponseDTO(data, "200", "Login successfully")));
        }
示例#19
0
        public bool LogBadRequest(string action, string userId, string errorMsg)
        {
            var logWritten = false;

            var log = new Log
            {
                Action      = action,
                User        = userId,
                DateTime    = DateTime.UtcNow.ToString(),
                Description = action + " occured. " + errorMsg // FailLogin occured
            };

            ResponseDTO <List <Log> > logList = GetLogs();

            logList.Data.Add(log);
            logWritten = WriteToLogFile(logList.Data);

            return(logWritten);
        }
示例#20
0
        public ResponseDTO Delete(int id)
        {
            ResponseDTO objresponse = new ResponseDTO();
            ConexionDTO cnn         = new ConexionDTO();

            cnn.procedimiento = "EliminarDetalleEntrada";
            cnn.parametros.Add("id", id);
            objresponse.codigo  = 1;
            objresponse.mensaje = string.Empty;

            try {
                var dt = new Conexion().ConsultarSPDT(cnn);
            } catch (System.Exception e) {
                objresponse.codigo  = -1;
                objresponse.mensaje = e.Message;
            }

            return(objresponse);
        }
示例#21
0
        public ResponseDTO GetAllNatarjConfigurations()
        {
            ResponseDTO responseDTO = new ResponseDTO();

            responseDTO.Status  = true;
            responseDTO.Message = "All Natraj Configurations";
            List <NatrajConfigurationDTO> natrajConfigurationDTOList = new List <NatrajConfigurationDTO>();
            var natrajConfigurationList = unitOfWork.ConfigurationRepository.GetAll();

            if (natrajConfigurationList != null && natrajConfigurationList.Count() > 0)
            {
                foreach (var natrajConfiguration in natrajConfigurationList)
                {
                    natrajConfigurationDTOList.Add(NatrajConfigurationConvertor.ConvertToNatrajConfigurationDTO(natrajConfiguration));
                }
            }
            responseDTO.Data = natrajConfigurationDTOList;
            return(responseDTO);
        }
示例#22
0
        public override void OnActionExecuting(ActionExecutingContext ctx)
        {
            base.OnActionExecuting(ctx);
            var    allHeaders = this.ControllerContext.HttpContext.Request.Headers;
            string Token = "", ClientID = "", CompanyID = "", UserID = "", PersonID = "", ProjectID = "";

            if (allHeaders.ContainsKey("Token"))
            {
                Token = allHeaders["Token"];
            }
            if (allHeaders.ContainsKey("ClientID"))
            {
                ClientID = allHeaders["ClientID"];
            }
            if (allHeaders.ContainsKey("CompanyID"))
            {
                CompanyID = allHeaders["CompanyID"];
            }
            if (allHeaders.ContainsKey("UserID"))
            {
                UserID = allHeaders["UserID"];
            }
            if (allHeaders.ContainsKey("PersonID"))
            {
                PersonID = allHeaders["PersonID"];
            }
            if (allHeaders.ContainsKey("ProjectID"))
            {
                ProjectID = allHeaders["ProjectID"];
            }

            this._request  = new RequestDTO();
            this._response = new ResponseDTO();

            this._request.Token     = this._response.Token = Token;
            this._request.ClientID  = this._response.ClientID = this.GetIntValue(ClientID);
            this._request.CompanyID = this._response.CompanyID = this.GetIntValue(CompanyID);
            this._request.UserID    = this._response.UserID = UserID;
            this._request.PersonID  = this._response.PersonID = this.GetIntValue(PersonID);
            this._request.ProjectID = this._response.ProjectID = this.GetIntValue(ProjectID);

            this.IsTokenVallid();
        }
        public ResponseDTO GetDistributionCenterByCenterId(int dcId)
        {
            ResponseDTO           responseDTO           = new ResponseDTO();
            DistributionCenterDTO distributionCenterDTO = null;
            var distributionCenter = unitOfWork.DistributionCenterRepository.GetById(dcId);

            if (distributionCenter != null)
            {
                distributionCenterDTO = DistributionCenterConvertor.ConvertToDistributionCenterDto(distributionCenter);
                responseDTO.Status    = true;
                responseDTO.Message   = "Distribution Center Details By DC Id";
                responseDTO.Data      = distributionCenterDTO;
            }
            else
            {
                throw new PlatformModuleException("Distribution Center Details Not Found");
            }
            return(responseDTO);
        }
示例#24
0
        public ResponseDTO GetVLCById(int vlcId)
        {
            ResponseDTO responseDTO = new ResponseDTO();
            VLCDTO      vlcDto      = null;
            var         vlc         = unitOfWork.VLCRepository.GetById(vlcId);

            if (vlc != null)
            {
                vlcDto              = VLCConvertor.ConvertToVLCDto(vlc);
                responseDTO.Status  = true;
                responseDTO.Message = "VLC Details By VLC";
                responseDTO.Data    = vlcDto;
            }
            else
            {
                throw new PlatformModuleException("VLC Details Not Found");
            }
            return(responseDTO);
        }
示例#25
0
        //Post api/Customer

        public IHttpActionResult Post([FromBody] CustomerDto customer)
        {
            try
            {
                if (customer == null)
                {
                    return(Ok(ResponseHelper.CreateResponseDTOForException("Argument Null")));
                }
                //Create New Customer
                ResponseDTO responseDTO = _customerService.AddCustomer(customer);

                return(Ok(responseDTO));
            }
            catch (PlatformModuleException ex)
            {
                //Write Log Here
                return(Ok(ResponseHelper.CreateResponseDTOForException(ex.Message)));
            }
        }
示例#26
0
        public async Task <ActionResult <BankAccountTransaction> > GetBankAccountTransaction(int id)
        {
            ResponseDTO <BankAccountTransactionDTO> response = new ResponseDTO <BankAccountTransactionDTO>();
            ListDTO <BankAccountTransactionDTO>     list     = new ListDTO <BankAccountTransactionDTO>();
            var bankList = _banksManager.GetTransactionById(id);

            if (bankList != null)
            {
                response.Data    = bankList;
                response.Message = "Transactions are retrieved successfully";
                response.Success = true;
                return(Ok(response));
            }
            response.Data    = null;
            response.Message = "Transactions are not retrieved successfully";
            response.Success = false;

            return(Ok(response));
        }
示例#27
0
        public ResponseDTO GetCustomerListForSearchByVLCId(int vlcId)
        {
            ResponseDTO responseDTO = new ResponseDTO();

            List <CustomerSearchDTO> customerList = new List <CustomerSearchDTO>();
            var customers = unitOfWork.CustomerRepository.GetCustomerListForSearchByVLCId(vlcId);

            if (customers != null)
            {
                foreach (var customer in customers)
                {
                    customerList.Add(CustomerConvertor.ConvertToCustomerSearchDto(customer));
                }
            }
            responseDTO.Status  = true;
            responseDTO.Message = String.Format("List of Customers By VLC Id");
            responseDTO.Data    = customerList;
            return(responseDTO);
        }
示例#28
0
        public async Task <ActionResult <CryptoAccount> > GetCryptoAccount(int id)
        {
            ResponseDTO <CryptoAccountDTO> response = new ResponseDTO <CryptoAccountDTO>();
            ListDTO <CryptoAccountDTO>     list     = new ListDTO <CryptoAccountDTO>();

            list = _cryptoManager.GetCryptoAccountById(id);
            if (list != null)
            {
                response.Data    = list;
                response.Message = "List is retrieved successfully";
                response.Success = true;
                return(Ok(response));
            }
            response.Data    = null;
            response.Message = "List is not retrieved successfully";
            response.Success = false;

            return(NotFound(response));
        }
        public ResponseDTO CrearRegistro([FromBody] AccountUserDTO value)
        {
            var Response = new ResponseDTO();

            Data.ControlCenter.Model.AccountUser u = new Data.ControlCenter.Model.AccountUser();
            u = AutoMapper.Mapper.Map <AccountUserDTO, Data.ControlCenter.Model.AccountUser>(value);

            FuncionLogActualizaciones L = new FuncionLogActualizaciones();

            L.LogCreacion(u.Log);
            uR.SaveOrUpdate(u);
            if (u.EntityID > 0)
            {
                Response.Success = true;
                Response.Message = "Creado";
            }

            return(Response);
        }
示例#30
0
        public void OnException(ExceptionContext context)
        {
            int statusCode = 500;

            /*
             *  Ustedes podrian tener definida una lista de codigos
             *  para indicar la response independiente de los statusCode.
             *  Por ejemplo:
             *
             *  1000 => cuando todo ocurre bien.
             *  2002 => cuando algo sale mal y no se identifico.
             *  2003 => cuando no se encuentra algo.
             *  2004 => cuando faltan argumentos.
             *
             *  Si bien en este caso son iguales a los statusCode de la resonse,
             *  podrian tener una granularidad mayor y ser especificos por error y entidad.
             *
             *  Lo ideal seria que este codigo lo tengan en la excepción que utilicen, por eso
             *  es buena práctica manjear sus propias excepciones.
             */
            ResponseDTO response = new ResponseDTO()
            {
                Code         = 2002,
                IsSuccess    = false,
                ErrorMessage = context.Exception.Message
            };

            if (context.Exception is NullReferenceException)
            {
                statusCode    = 404;
                response.Code = 2003;
            }
            if (context.Exception is ArgumentException)
            {
                statusCode    = 400;
                response.Code = 2004;
            }

            context.Result = new ObjectResult(response)
            {
                StatusCode = statusCode
            };
        }
示例#31
0
        public async Task <IActionResult> UpdateUser(int id, UpdateDto dto)
        {
            var user = await repo.GetUserById(id);

            if (user == null)
            {
                return(BadRequest(ResponseDTO.NotFound()));
            }

            user.Username    = dto.Username;
            user.Email       = dto.Email;
            user.RoleId      = dto.RoleId;
            user.Name        = dto.Name;
            user.PhoneNumber = dto.PhoneNumber;

            await repo.Update(user);

            return(Ok(ResponseDTO.Ok(user)));
        }
示例#32
0
        //Post api/Customer

        public IHttpActionResult Post([FromBody] VLCMilkCollectionDTO vLCMilkCollectionDTO)
        {
            try
            {
                if (vLCMilkCollectionDTO == null)
                {
                    Ok(ResponseHelper.CreateResponseDTOForException("Argument Null"));
                }
                //Create New Customer
                ResponseDTO responseDTO = _vlcMilkCollectionService.AddVLCMilkCollection(vLCMilkCollectionDTO);

                return(Ok(responseDTO));
            }
            catch (PlatformModuleException ex)
            {
                //Write Log Here
                return(Ok(ResponseHelper.CreateResponseDTOForException(ex.Message)));
            }
        }
示例#33
0
        public ResponseDTO UpdateCaseDocumentStatus(RequestDTO<CaseDocument> request)
        {
            ResponseDTO response = new ResponseDTO();

            CaseDocument caseDocumentCriteria = request.Inputs.First();

            if (caseDocumentCriteria != null)
            {
                var modifiedCaseDoc = UnitOfWork.CaseDocumentRepo.GetFirst(x => x.CaseDocumentId == caseDocumentCriteria.CaseDocumentId);

                modifiedCaseDoc.CaseDocumentStatusId = caseDocumentCriteria.CaseDocumentStatusId;
                UnitOfWork.CaseDocumentRepo.Update(modifiedCaseDoc);
                UnitOfWork.Commit();
                response.Results = ResponseResults.Success;

            }
            else
            {
                response = ResponseUtility.CreateErrorResponse(
                                ResponseResults.FailAndNoRetry,
                                new string[] { CaseDocumentExceptions.InvalidCaseDocument }
                                );
            }

            return response;
        }
示例#34
0
        // TODO
        public ResponseDTO UpdateMember(RequestDTO<McMember> request)
        {
            ResponseDTO response = new ResponseDTO();

            return response;
        }
示例#35
0
        // TODO
        public ResponseDTO CreateMemberAttribute(RequestDTO<McMemberAttribute> request)
        {
            ResponseDTO response = new ResponseDTO();

            return response;
        }