Exemplo n.º 1
0
        public async Task <IActionResult> PutCustomerType(Guid id, CustomerTypeDTO customerType)
        {
            var type = await _context.CustomerType.FindAsync(id);

            if (type == null)
            {
                return(BadRequest());
            }

            type.Name = customerType.Name;
            _context.Update(type);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <ActionResult> pvwCustomerType([FromBody] CustomerTypeDTO _sarpara)
        {
            CustomerTypeDTO _CustomerType = new CustomerTypeDTO();

            try
            {
                string     baseadress = config.Value.urlbase;
                HttpClient _client    = new HttpClient();
                _client.DefaultRequestHeaders.Add("Authorization", "Bearer " + HttpContext.Session.GetString("token"));
                var result = await _client.GetAsync(baseadress + "api/CustomerType/GetCustomerTypeById/" + _sarpara.CustomerTypeId);

                string valorrespuesta = "";
                if (result.IsSuccessStatusCode)
                {
                    valorrespuesta = await(result.Content.ReadAsStringAsync());
                    _CustomerType  = JsonConvert.DeserializeObject <CustomerTypeDTO>(valorrespuesta);
                }

                if (_CustomerType == null)
                {
                    _CustomerType = new CustomerTypeDTO();
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                throw ex;
            }



            return(PartialView(_CustomerType));
        }
Exemplo n.º 3
0
        public async Task <ActionResult <CustomerType> > SaveCustomerType([FromBody] CustomerTypeDTO _CustomerTypeS)
        {
            string valorrespuesta = "";

            try
            {
                CustomerType _CustomerType = new CustomerType();
                string       baseadress    = config.Value.urlbase;
                HttpClient   _client       = new HttpClient();
                _client.DefaultRequestHeaders.Add("Authorization", "Bearer " + HttpContext.Session.GetString("token"));
                var result = await _client.GetAsync(baseadress + "api/CustomerType/GetCustomerTypeByCustomerTypeName/" + _CustomerTypeS.CustomerTypeName);

                if (result.IsSuccessStatusCode)
                {
                    valorrespuesta = await(result.Content.ReadAsStringAsync());
                    _CustomerType  = JsonConvert.DeserializeObject <CustomerType>(valorrespuesta);
                    if (_CustomerType != null && _CustomerTypeS.CustomerTypeId == 0)
                    {
                        if (_CustomerType.CustomerTypeName == _CustomerTypeS.CustomerTypeName)
                        {
                            return(await Task.Run(() => BadRequest($"Ya existe un Tipo de cliente con el mismo nombre.")));
                        }
                    }
                }
                result = await _client.GetAsync(baseadress + "api/CustomerType/GetCustomerTypeById/" + _CustomerTypeS.CustomerTypeId);

                _CustomerTypeS.FechaModificacion   = DateTime.Now;
                _CustomerTypeS.UsuarioModificacion = HttpContext.Session.GetString("user");
                if (result.IsSuccessStatusCode)
                {
                    valorrespuesta = await(result.Content.ReadAsStringAsync());
                    _CustomerType  = JsonConvert.DeserializeObject <CustomerTypeDTO>(valorrespuesta);
                }

                if (_CustomerType == null)
                {
                    _CustomerType = new Models.CustomerType();
                }

                if (_CustomerType.CustomerTypeId == 0)
                {
                    _CustomerTypeS.FechaCreacion   = DateTime.Now;
                    _CustomerTypeS.UsuarioCreacion = HttpContext.Session.GetString("user");
                    var insertresult = await Insert(_CustomerTypeS);
                }
                else
                {
                    _CustomerTypeS.UsuarioCreacion = _CustomerType.UsuarioCreacion;
                    _CustomerTypeS.FechaCreacion   = _CustomerType.FechaCreacion;
                    var updateresult = await Update(_CustomerType.CustomerTypeId, _CustomerTypeS);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                throw ex;
            }

            return(Json(_CustomerTypeS));
        }
        public IEnumerable <CustomerTypeDTO> LoadFullCustomerType()
        {
            DataTable dataTable = DataProvider.Instance.ExcuteDataReader("USP_LoadFullCustomerType");

            foreach (DataRow row in dataTable.Rows)
            {
                CustomerTypeDTO customer = new CustomerTypeDTO(row, dataTable);
                listCustomerType.Add(customer);
            }
            return(listCustomerType);
        }
Exemplo n.º 5
0
        public async Task <ActionResult <CustomerType> > PostCustomerType(CustomerTypeDTO customerType)
        {
            var type = new CustomerType()
            {
                Name = customerType.Name
            };

            _context.CustomerType.Add(type);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCustomerType", new { id = type.Id }, type));
        }
Exemplo n.º 6
0
        private CustomerTypeDTO LoadEntityData(CustomerType entity)
        {
            var myDto = new CustomerTypeDTO()
            {
                Id          = entity.Id,
                Name        = entity.Name,
                Description = entity.Description
            };


            return(myDto);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Clear the controls
 /// </summary>
 private void ClearControls()
 {
     CustomerCode = string.Empty;
     SelectedType = null;
     First_Name = string.Empty;
     LastName = string.Empty;
     Email = string.Empty;
     Phone = string.Empty;
     Mobile = string.Empty;
     SelectedStatus = null;
     PaymentPeriod = 0;
     CreditLimit = 0;
     BuildingName = string.Empty;
     HouseNo = string.Empty;
     SelectedCountry = null;
     SelectedTownCity = null;
     SelectedLocality = null;
     SelectedStreet = null;
     SelectedPostalCode = null;
 }