public ResponseStatus SaveCustomerData(CustomerEntryModel model) { ResponseStatus respponse = new ResponseStatus(); CategoryModel data = new CategoryModel(); using (storefeedback_androidEntities context = new storefeedback_androidEntities()) { feedbackcustomermaster c = new feedbackcustomermaster(); c.CustomerName = model.CustomerName; c.PhoneNumber = model.PhoneNumber; c.EmailId = model.Email; c.Address = model.Address; context.feedbackcustomermasters.Add(c); var result = context.SaveChanges(); if (result > 0) { respponse.isSuccess = true; respponse.serverResponseTime = System.DateTime.Now; } else { respponse.isSuccess = false; respponse.serverResponseTime = System.DateTime.Now; } } return(respponse); }
public async Task <ActionResult> SaveCustomer(CustomerEntryModel model) { CustomerEntryModelObjectRootModel obj = new CustomerEntryModelObjectRootModel(); string url = GetUrl(2); url = url + "WebSiteLogin/SaveCustomerData?Name=" + model.CustomerName + "&PhoneNo=" + model.PhoneNumber + "&EmailId=" + model.Email + "&Address=" + model.Address + ""; using (HttpClient client = new HttpClient()) { HttpResponseMessage responseMessage = await client.GetAsync(url); if (responseMessage.IsSuccessStatusCode) { var response = responseMessage.Content.ReadAsStringAsync().Result; var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; obj = JsonConvert.DeserializeObject <CustomerEntryModelObjectRootModel>(response, settings); if (obj.data.isSuccess) { ViewBag.Message = "Save Data Successfully!"; } else { ViewBag.Message = "Data Not Saved!"; } } } TempData["message"] = ViewBag.Message; return(RedirectToAction("Index")); }
public HttpResponseMessage SaveCustomerData(string Name, string PhoneNo, string EmailId, string Address) { CustomerEntryModel model = new CustomerEntryModel(); model.CustomerName = Name; model.PhoneNumber = PhoneNo; model.Email = EmailId; model.Address = Address; ResponseStatus response = new ResponseStatus(); try { var data = _repository.SaveCustomerData(model); return(Request.CreateResponse(HttpStatusCode.OK, new { data })); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Something Worng !", ex)); } }