public ActionResult UpdateCustomerPriceDetails([FromBody] CustomerPriceDetailRequest request) { bool isSucess = false, customerPriceDeleteResult = false; string messageAlert = string.Empty; long customerIdResult = 0; var currentUserId = HttpContext.Session.GetString(LookupKey.SessionVariables.UserId).IsNull() ? 0 : Convert.ToInt64(HttpContext.Session.GetString(LookupKey.SessionVariables.UserId)); request.CreatedBy = currentUserId; request.CreatedTime = DateTime.Now; var productPriceResult = _customerService.GetAllCustomerPricingDetails().Where(m => m.CustomerId == request.CustomerId && m.ProductId == request.ProductId).FirstOrDefault(); if (productPriceResult.IsNull()) { customerIdResult = _customerService.SaveCustomerPrice(request); isSucess = true; return(Ok(new { isSuccess = isSucess, messageAlert = messageAlert })); } customerPriceDeleteResult = _customerService.DeleteCustomerPriceDetails(request); if (!customerPriceDeleteResult) { return(Ok(new { isSucess = isSucess, messageAlert = Messages.ServerError })); } customerIdResult = _customerService.SaveCustomerPrice(request); if (customerIdResult < 0) { return(Ok(new { isSucess = isSucess, messageAlert = Messages.ServerError })); } isSucess = true; var response = new { isSuccess = isSucess, messageAlert = messageAlert }; return(Ok(response)); }
public static dbentities.CustomerPrice DtoToEntity(this CustomerPriceDetailRequest request) { dbentities.CustomerPrice entity = null; if (request != null) { entity = new dbentities.CustomerPrice { CustomerID = request.CustomerId, ProductID = request.ProductId, ProductPrice = request.ProductPrice, CreatedBy = request.CreatedBy, CreatedTime = request.CreatedTime, }; } return(entity); }