public JsonResult PostData(ServiceType serviceType) { ServiceType dataServiceType = new ServiceType(); dataServiceType.Name = serviceType.Name; if (serviceType.Id > 0) { dataServiceType.Id = serviceType.Id; db.Update(dataServiceType); } else { db.Add(dataServiceType); } return(Json("success", JsonRequestBehavior.AllowGet)); }
public AddServiceTypeResponse Add(AddServiceTypeRequest request) { try { var response = new AddServiceTypeResponse(); var bc = new ServiceTypeComponent(); response.Result = bc.Add(request.ServiceType); return(response); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }