public ActionResult AddOrEdit(int id = 0) { if (id == 0) { int contectId = 3; HttpResponseMessage response = GlobalVeriables.WebApiClient.GetAsync("Contacts/" + contectId.ToString()).Result; MVCContactsModel contectmodel = response.Content.ReadAsAsync <MVCContactsModel>().Result; int companyId = 2; HttpResponseMessage responseCompany = GlobalVeriables.WebApiClient.GetAsync("CompanyInformations/" + companyId.ToString()).Result; MVCCompanyModel companyModel = responseCompany.Content.ReadAsAsync <MVCCompanyModel>().Result; //var Logo = companyModel.CompanyLogo; //var Logos = new StringBuilder(Logo); //Logos.Remove(0, 2); //Logos.Insert(0,'~'); //companyModel.CompanyLogo = Logos.ToString(); ViewBag.Contentdata = contectmodel; ViewBag.Companydata = companyModel; return(View(new MVCPurchaseViewModel())); } else { HttpResponseMessage response = GlobalVeriables.WebApiClient.GetAsync("Purchase/" + id.ToString()).Result; return(View(response.Content.ReadAsAsync <MVCPurchaseViewModel>().Result)); } }
public ActionResult AddOrEdit(MVCContactsModel ContactModel) { if (!ModelState.IsValid) { return(View(ContactModel)); } else { if (ContactModel.ContactsId == null) { ContactModel.Company_Id = 2; ContactModel.UserId = 1; ContactModel.Addeddate = Convert.ToDateTime(System.DateTime.Now.ToShortDateString()); HttpResponseMessage response = GlobalVeriables.WebApiClient.PostAsJsonAsync("Contacts", ContactModel).Result; TempData["SuccessMessage"] = "Saved Successfully"; } else { HttpResponseMessage response = GlobalVeriables.WebApiClient.PutAsJsonAsync("Contacts/" + ContactModel.ContactsId, ContactModel).Result; TempData["SuccessMessage"] = "Updated Successfully"; } } return(RedirectToAction("Index")); }
public ActionResult AddOrEdit(int id = 0) { if (id == 0) { int contectId = 1; HttpResponseMessage response = GlobalVeriables.WebApiClient.GetAsync("Contacts/" + contectId.ToString()).Result; MVCContactsModel contectmodel = response.Content.ReadAsAsync <MVCContactsModel>().Result; int companyId = 2; HttpResponseMessage responseCompany = GlobalVeriables.WebApiClient.GetAsync("CompanyInformations/" + companyId.ToString()).Result; MVCCompanyModel companyModel = responseCompany.Content.ReadAsAsync <MVCCompanyModel>().Result; ViewBag.Contentdata = contectmodel; ViewBag.Companydata = companyModel; return(View(new MVCSalesViewModel())); } else { HttpResponseMessage response = GlobalVeriables.WebApiClient.GetAsync("Sales/" + id.ToString()).Result; return(View(response.Content.ReadAsAsync <MVCSalesViewModel>().Result)); } }