private void PriceAcceptBtn_Click(object sender, EventArgs e) { if (Id != 0) { UpdatePrice.Invoke(sender, EventArgs.Empty); } else { AddNewPrice.Invoke(sender, EventArgs.Empty); } UpdatePriceDataGridView(); ClearPriceGroupBoxFields(); }
public IHttpActionResult AddNewPrice(AddNewPrice AddTPrice) { if (AddTPrice == null) { return(BadRequest("Please Provide Valid New Price in correct format.")); } if (!ModelState.IsValid) { string modelErrors = string.Join(Environment.NewLine, ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage)); return(BadRequest(modelErrors)); } try { TransportationPrice transportationPrice = new TransportationPrice(); transportationPrice.TransportationProviderID = AddTPrice.TransportationProviderID; transportationPrice.TransportationModeID = AddTPrice.TransportationModeID; transportationPrice.Price = AddTPrice.Price; bool response = adminTManagerBL.AddNewPrice(transportationPrice); if (!response) { return(NotFound()); } else { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NoContent, "Successfully posted New Price"))); } } catch (Exception ex) { if (ex.GetType().IsAssignableFrom(typeof(DbUpdateConcurrencyException))) { ModelState.AddModelError("DuplicateTransportationPriceAdditionError", "Combination of price and Transport already exist"); return(BadRequest(ModelState)); } return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Some error occoured while trying to add new transportation price"))); } }