Пример #1
0
        public ActionResult AddOrEdit(MVCCompanyModel CompnayModel, HttpPostedFileBase file)
        {
            if (!ModelState.IsValid)
            {
                return(View(CompnayModel));
            }
            else
            {
                if (file != null)
                {
                    string filename  = Path.GetFileNameWithoutExtension(file.FileName);
                    string Extention = Path.GetExtension(file.FileName);

                    filename = filename + DateTime.Now.ToString("yymmssfff") + Extention;

                    CompnayModel.CompanyLogo = "~/Images/" + filename;
                    filename = Path.Combine(Server.MapPath("~/Images/"), filename);
                    file.SaveAs(filename);
                }

                if (CompnayModel.CompanyId == null)
                {
                    HttpResponseMessage response = GlobalVeriables.WebApiClient.PostAsJsonAsync("CompanyInformations", CompnayModel).Result;
                    TempData["SuccessMessage"] = "Saved Successfully";
                }
                else
                {
                    HttpResponseMessage response = GlobalVeriables.WebApiClient.PutAsJsonAsync("CompanyInformations/" + CompnayModel.CompanyId, CompnayModel).Result;
                    TempData["SuccessMessage"] = "Updated Successfully";
                }
            }
            return(RedirectToAction("Index"));
        }
Пример #2
0
        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(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));
            }
        }