private void updateAgent() { Agent agent = new Agent(); if (agentmobileNoTextBox.Text.ToString() == "") { MessageBox.Show("Enter Mobile No."); } else { if (agentnameTextBox.Text.ToString() == "") { MessageBox.Show("Enter Name"); } else { if (agentaddressTextBox.Text.ToString() == "") { MessageBox.Show("Enter Address"); } else { try { agent.Mobile_No = agentmobileNoTextBox.Text; } catch (Exception) { MessageBox.Show("Already Exist"); } agent.Address = agentaddressTextBox.Text; agent.Name = agentnameTextBox.Text; AgentServices agentservices = new AgentServices(); if (agentservices.Update(agent) == 1) { MessageBox.Show("Successfully Updated"); } else { MessageBox.Show("Update Failed"); } } } } }
public JsonResult Create(BusinessEntitiesViewModel businessEntitiesViewModel) { if (businessEntitiesViewModel.BusinessId > 0) { var file = businessEntitiesViewModel.ImageFile; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); string extension = Path.GetExtension(file.FileName); string filenamewithoutextension = Path.GetFileNameWithoutExtension(file.FileName); if (string.Equals(extension, ".jpg", StringComparison.OrdinalIgnoreCase) || string.Equals(extension, ".png", StringComparison.OrdinalIgnoreCase) || string.Equals(extension, ".gif", StringComparison.OrdinalIgnoreCase) || string.Equals(extension, ".jpeg", StringComparison.OrdinalIgnoreCase)) { //file.SaveAs(Server.MapPath("/AppFile/Images/" + file.FileName)); businessEntitiesViewModel.LogoImagePath = "~/AppFiles/Images/" + fileName; file.SaveAs(Path.Combine(Server.MapPath("~/AppFiles/Images/"), fileName)); var data = AgentServices.Update(businessEntitiesViewModel); return(Json(data, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = "Image Extension is Worng" })); } } else { var data = AgentServices.Update(businessEntitiesViewModel); return(Json(data, JsonRequestBehavior.AllowGet)); } } else { var file = businessEntitiesViewModel.ImageFile; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); string extension = Path.GetExtension(file.FileName); string filenamewithoutextension = Path.GetFileNameWithoutExtension(file.FileName); if (string.Equals(extension, ".jpg", StringComparison.OrdinalIgnoreCase) || string.Equals(extension, ".png", StringComparison.OrdinalIgnoreCase) || string.Equals(extension, ".gif", StringComparison.OrdinalIgnoreCase) || string.Equals(extension, ".jpeg", StringComparison.OrdinalIgnoreCase)) { //file.SaveAs(Server.MapPath("/AppFile/Images/" + file.FileName)); businessEntitiesViewModel.LogoImagePath = "~/AppFiles/Images/" + fileName; file.SaveAs(Path.Combine(Server.MapPath("~/AppFiles/Images/"), fileName)); var data = AgentServices.Create(businessEntitiesViewModel); return(Json(data, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = "Image Extension is Worng" })); } } else { return(Json(new { success = "Image Not Fount" })); } } }