示例#1
0
        public ActionResult CashCompany()
        {
            CountryController countryController = new CountryController();

            ViewBag.Countries = countryController.Countries();
            return(View(new CompnayModel()));
        }
示例#2
0
        public ActionResult Create()
        {
            CountryController countryController = new CountryController();

            ViewBag.Countries = countryController.Countries();
            return(View(new VenderViewModel()));
        }
示例#3
0
        public ActionResult CompanyEdit(int id)
        {
            try
            {
                CompnayModel compnayModel = new CompnayModel();

                PagingParameterModel pagingParameterModel = new PagingParameterModel
                {
                    Id = id
                };
                var companyData = webServices.Post(pagingParameterModel, "Company/CompanyById");
                if (companyData.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    if (companyData.Data != "[]" && companyData.Data != null)
                    {
                        compnayModel = (new JavaScriptSerializer().Deserialize <CompnayModel>(companyData.Data.ToString()));
                    }
                }

                CountryController countryController = new CountryController();
                ViewBag.Countries = countryController.Countries();

                if (Request.IsAjaxRequest())
                {
                    return(Json(compnayModel, JsonRequestBehavior.AllowGet));
                }

                return(View(compnayModel));
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#4
0
        public ActionResult Details(int Id)
        {
            try
            {
                var venderResult = webServices.Post(new VenderViewModel(), "Vender/Edit/" + Id);

                if (venderResult.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    venderViewModel = (new JavaScriptSerializer().Deserialize <VenderViewModel>(venderResult.Data.ToString()));
                }

                if (Request.IsAjaxRequest())
                {
                    return(Json(venderViewModel, JsonRequestBehavior.AllowGet));
                }

                CountryController countryController = new CountryController();

                ViewBag.Countries = countryController.Countries();

                return(View(venderViewModel));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#5
0
        public ActionResult AddUpdateState()
        {
            CountryController countryController = new CountryController();

            ViewBag.Countries = countryController.Countries();
            return(View(new StateViewModel()));
        }
示例#6
0
        public ActionResult EditState(int Id, String Name, int CountryId = 0)
        {
            StateViewModel stateViewModel = new StateViewModel
            {
                Id        = Id,
                States    = Name,
                CountryId = CountryId,
            };
            CountryController countryController = new CountryController();

            ViewBag.Countries = countryController.Countries();

            return(View("AddUpdateState", stateViewModel));
        }
        public ActionResult EditCity(int Id, String Name, int StateId = 0)
        {
            CityViewModel cityViewModel = new CityViewModel();

            cityViewModel.Id       = Id;
            cityViewModel.CityName = Name;
            cityViewModel.StateId  = StateId;

            CountryController countryController = new CountryController();

            ViewBag.Countries = countryController.Countries();

            return(View("AddUpdateCity", CityViewModel));
        }
示例#8
0
        public ActionResult Create(VenderViewModel venderViewModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    CountryController countryController = new CountryController();
                    ViewBag.Countries = countryController.Countries();

                    return(View(venderViewModel));
                }
                else
                {
                    var venderResult = new ServiceResponseModel();
                    if (venderViewModel.Id < 1)
                    {
                        venderViewModel.CreatedBy = Convert.ToInt32(Session["UserId"]);
                        venderResult = webServices.Post(venderViewModel, "Vender/Add");
                    }
                    else
                    {
                        venderViewModel.UpdatedBy = Convert.ToInt32(Session["UserId"]);
                        venderResult = webServices.Post(venderViewModel, "Vender/Update");
                    }
                    if (venderResult.StatusCode == System.Net.HttpStatusCode.Accepted)
                    {
                        var reuslt = (new JavaScriptSerializer().Deserialize <int>(venderResult.Data));

                        return(RedirectToAction(nameof(Index)));
                    }
                    if (Request.IsAjaxRequest())
                    {
                        return(Json(venderViewModels, JsonRequestBehavior.AllowGet));
                    }

                    return(View(venderViewModel));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#9
0
        public ActionResult CashCompanyCreate(CompnayModel compnayModel, HttpPostedFileBase LogoUrl)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    CountryController countryController = new CountryController();
                    ViewBag.Countries = countryController.Countries();
                    return(View("CashCompany", compnayModel));
                }
                else
                {
                    using (HttpClient client = new HttpClient())
                    {
                        using (var content = new MultipartFormDataContent())
                        {
                            if (Request.Files.Count > 0)
                            {
                                if (LogoUrl != null)
                                {
                                    var    file      = LogoUrl;
                                    byte[] fileBytes = new byte[file.InputStream.Length + 1];
                                    file.InputStream.Read(fileBytes, 0, fileBytes.Length);
                                    var fileContent = new ByteArrayContent(fileBytes);
                                    fileContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("LogoUrl")
                                    {
                                        FileName = file.FileName
                                    };
                                    content.Add(fileContent);
                                }
                            }
                            content.Add(new StringContent("ClientDocs"), "ClientDocs");
                            content.Add(new StringContent(compnayModel.Name ?? ""), "Name");
                            content.Add(new StringContent(compnayModel.Street ?? ""), "street");
                            content.Add(new StringContent(compnayModel.Postcode ?? ""), "Postcode");
                            content.Add(new StringContent(compnayModel.City ?? ""), "City");
                            content.Add(new StringContent(compnayModel.Street ?? ""), "State");
                            content.Add(new StringContent(compnayModel.Country ?? ""), "Country");
                            content.Add(new StringContent(compnayModel.Email ?? ""), "Email");
                            content.Add(new StringContent(compnayModel.Phone ?? ""), "Phone");
                            content.Add(new StringContent(compnayModel.Cell ?? ""), "Cell");
                            content.Add(new StringContent(compnayModel.OwnerRepresentaive ?? ""), "OwnerRepresentaive");
                            content.Add(new StringContent(compnayModel.Remarks ?? ""), "Commentes");
                            content.Add(new StringContent(compnayModel.TRN ?? ""), "TRN");
                            content.Add(new StringContent(compnayModel.Address ?? ""), "Address");
                            content.Add(new StringContent("true"), "IsCashCompany");
                            //  var result1 = client.PostAsync("http://itmolen-001-site8.htempurl.com/api/Company/Add", content).Result;
                            var result = webServices.PostMultiPart(content, "Company/Add", true);
                            if (result.StatusCode == System.Net.HttpStatusCode.Accepted)
                            {
                                ViewBag.Message = "Created";
                                return(RedirectToAction(nameof(Index)));
                            }
                            else
                            {
                                ViewBag.Message = "Failed";
                                CountryController countryController = new CountryController();
                                ViewBag.Countries = countryController.Countries();
                                return(View("CashCompany", compnayModel));
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }