Exemplo n.º 1
0
        public ActionResult <bool> UpdateCustomer(CustomerUpdateRequestModel customerRequestModel)
        {
            var customerModel = _customerServices.GetById(customerRequestModel.Id);

            customerModel.Update(customerRequestModel);
            return(_customerServices.Update(customerRequestModel.Id, customerModel));
        }
Exemplo n.º 2
0
        public ActionResult SetIsHideUser(long id, bool isChecked)
        {
            var cus = customerServices.GetById(id);

            cus.IsHideUser = isChecked;
            customerServices.Commited();
            return(Json("ok", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        // GET: api/Customer/5
        public HttpResponseMessage Get(int id)
        {
            var customer = _customerServices.GetById(id);

            return(customer != null
                ? Request.CreateResponse(HttpStatusCode.OK, customer)
                : Request.CreateErrorResponse(HttpStatusCode.NotFound, "No Customer found for this id"));
        }
        public IActionResult GetById(int id)
        {
            var result = _customerServices.GetById(id);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Exemplo n.º 5
0
 public ActionResult <CustomerViewModel> GetById(int id)
 {
     try
     {
         _logger.LogInformation("Received get list Customer request");
         var result = _customerServices.GetById(id);
         return(Ok(_mapper.Map <CustomerViewModel>(result)));
     }
     catch (Exception exception)
     {
         _logger.LogError(exception, exception.Message);
         return(new StatusCodeResult(500));
     }
 }
Exemplo n.º 6
0
 public Customer Get(int id) => _customerServices.GetById(id);
Exemplo n.º 7
0
        public JsonResult CheckSuggest(int?id, string name, string modelName, int tabIndex)
        {
            var supps = new List <StockRecevingDiagloModel>();

            if (!id.HasValue)
            {
                id = 0;
            }
            switch (modelName)
            {
            case "Supplier":
                if (id != 0)
                {
                    var supplierById = supplierServices.GetSupplier(id.Value);
                    if (supplierById != null && supplierById.FullName == name)
                    {
                        return(Json("ok"));
                    }
                }
                supps =
                    supplierServices.GetAll()
                    .Where(x => (string.IsNullOrEmpty(name) || x.FullName.Contains(name))).OrderBy(x => x.FullName)
                    .Select(x => new StockRecevingDiagloModel {
                    Id = x.Id, Display = x.FullName, Other = "N/A"
                })
                    .ToList();
                if (!supps.Any())
                {
                    supps = supplierServices.GetAll().Select(x => new StockRecevingDiagloModel {
                        Id = x.Id, Display = x.FullName, Other = "N/A"
                    }).ToList();
                }
                break;

            case "Customer":
                var customer = new Customer();
                if (id != 0)
                {
                    customer = customerServices.GetById(id.Value);
                    if (customer != null && customer.FullName == name)
                    {
                        return(Json("ok"));
                    }
                }
                customer.FullName = name;
                supps             =
                    customerServices.GetQuery()
                    .Where(x => (string.IsNullOrEmpty(name) || x.FullName.Contains(name))).OrderBy(x => x.FullName)
                    .Select(x => new StockRecevingDiagloModel {
                    Id = x.Id, Display = x.FullName, Other = "N/A"
                })
                    .ToList();
                if (!supps.Any())
                {
                    supps = customerServices.GetQuery().Select(x => new StockRecevingDiagloModel {
                        Id = x.Id, Display = x.FullName, Other = "N/A"
                    }).ToList();
                }
                break;

            case "Country":
                if (id != 0)
                {
                    var countryById = stockReceivingService.GetAllCountry().FirstOrDefault(x => x.Id == id);
                    if (countryById != null && countryById.CountryName == name)
                    {
                        return(Json("ok"));
                    }
                }
                supps =
                    stockReceivingService.GetAllCountry()
                    .Where(x => (string.IsNullOrEmpty(name) || x.CountryName.Contains(name))).OrderBy(x => x.CountryName)
                    .Select(x => new StockRecevingDiagloModel {
                    Id = x.Id, Display = x.CountryName, Other = "N/A"
                })
                    .ToList();
                if (!supps.Any())
                {
                    supps = stockReceivingService.GetAllCountry().Select(x => new StockRecevingDiagloModel {
                        Id = x.Id, Display = x.CountryName, Other = "N/A"
                    }).ToList();
                }
                break;

            case "Product":
                if (id != 0 && productServices.Exists(name))
                {
                    return(Json("ok"));
                }

                supps = productServices.GetAll(name, 20);
                if (!supps.Any())
                {
                    supps = productServices.GetAll().Select(x => new StockRecevingDiagloModel {
                        Id = x.Id, Display = x.Name, Other = "N/A"
                    }).ToList();
                }
                break;
            }
            ViewData["TabIndexAdd"] = tabIndex;
            ViewData["nameSearch"]  = name;
            ViewData["modelName"]   = modelName;
            var html = this.RenderPartialView("_EnterSearchDialogView", supps);

            return(Json(html, JsonRequestBehavior.AllowGet));
        }