Exemplo n.º 1
0
        public ActionResult Details(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()));
                    }
                }

                if (Request.IsAjaxRequest())
                {
                    return(Json(compnayModel, JsonRequestBehavior.AllowGet));
                }
                return(View(compnayModel));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            try
            {
                CompnayModel compnayModel = new CompnayModel();

                PagingParameterModel pagingParameterModel = new PagingParameterModel
                {
                    Id = id
                };
                var companyData = webServices.Post(pagingParameterModel, "AWFCompany/Edit");
                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();

                return(View(compnayModel));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 3
0
        public ActionResult CashCompanyCreate(CompnayModel compnayModel, HttpPostedFileBase LogoUrl)
        {
            try
            {
                if (Request.Files.Count > 0)
                {
                    var file = LogoUrl;

                    using (HttpClient client = new HttpClient())
                    {
                        using (var content = new MultipartFormDataContent())
                        {
                            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("Name"), "Name");
                            content.Add(new StringContent("street Data"), "Street");
                            content.Add(new StringContent(compnayModel.Postcode == null ? "" : compnayModel.Postcode), "Postcode");
                            content.Add(new StringContent(compnayModel.City == null ? "" : compnayModel.City), "City");
                            content.Add(new StringContent(compnayModel.Street == null ? "" : compnayModel.Street), "State");
                            content.Add(new StringContent(compnayModel.Country == null ? "" : compnayModel.Country), "Country");
                            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";
                            }
                            else
                            {
                                ViewBag.Message = "Failed";
                            }
                        }
                    }
                }
                return(View());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 4
0
        public ActionResult CompanyInformation(int id)
        {
            UserViewModel userViewModel = new UserViewModel();

            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()));
                    }
                }
                var usercCompany = Session["userCompanyViewModel"] as UserCompanyViewModel;
                userViewModel.UserName = usercCompany.UserName;
                var userList = webServices.Post(userViewModel, "User/UserInformationByUserName");

                if (userList.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    userViewModel = (new JavaScriptSerializer().Deserialize <UserViewModel>(userList.Data.ToString()));


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

                ViewBag.userViewModel = userViewModel;

                return(View(compnayModel));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 5
0
        public ActionResult AdminCompanyInformation(int id)
        {
            UserViewModel userViewModel = new UserViewModel();

            try
            {
                CompnayModel compnayModel = new CompnayModel();

                SearchViewModel searchViewModel = new SearchViewModel
                {
                    Id = id
                };

                var companyData = webServices.Post(searchViewModel, "AWFCompany/Edit");
                if (companyData.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    if (companyData.Data != "[]" && companyData.Data != null)
                    {
                        compnayModel = (new JavaScriptSerializer().Deserialize <CompnayModel>(companyData.Data.ToString()));
                    }
                }
                var usercCompany = Session["userCompanyViewModel"] as UserCompanyViewModel;
                userViewModel.UserName = usercCompany.UserName;
                var userList = webServices.Post(userViewModel, "User/UserInformationByUserName");

                if (userList.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    userViewModel = (new JavaScriptSerializer().Deserialize <UserViewModel>(userList.Data.ToString()));
                }

                ViewBag.userViewModel = userViewModel;

                return(View(compnayModel));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 6
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;
            }
        }
Exemplo n.º 7
0
        public ActionResult Update(CompnayModel compnayModel, HttpPostedFileBase LogoUrl)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View("Edit", compnayModel));
                }
                else
                {
                    using (HttpClient client = new HttpClient())
                    {
                        using (var content = new MultipartFormDataContent())
                        {
                            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");
                            }
                            else
                            {
                                content.Add(new StringContent(compnayModel.LogoUrl ?? ""), "LogoUrl");
                            }


                            content.Add(new StringContent(compnayModel.Id.ToString()), "Id");
                            content.Add(new StringContent(compnayModel.Name ?? ""), "Name");
                            content.Add(new StringContent(compnayModel.Street ?? ""), "Street");
                            string UserId = Session["UserId"].ToString();
                            content.Add(new StringContent(UserId), "UpdatedBy");
                            content.Add(new StringContent(compnayModel.Postcode ?? ""), "Postcode");
                            content.Add(new StringContent(compnayModel.City ?? ""), "City");
                            content.Add(new StringContent(compnayModel.Address ?? ""), "Address");
                            content.Add(new StringContent(compnayModel.State ?? ""), "State");
                            content.Add(new StringContent(compnayModel.Country ?? ""), "Country");
                            content.Add(new StringContent(compnayModel.Cell ?? ""), "Cell");
                            content.Add(new StringContent(compnayModel.Phone ?? ""), "Phone");
                            content.Add(new StringContent(compnayModel.Email ?? ""), "Email");
                            content.Add(new StringContent(compnayModel.Web ?? ""), "Web");
                            content.Add(new StringContent(compnayModel.TRN ?? ""), "TRN");
                            content.Add(new StringContent(compnayModel.Remarks ?? ""), "Remarks");
                            content.Add(new StringContent(compnayModel.OwnerRepresentaive ?? ""), "OwnerRepresentaive");
                            content.Add(new StringContent("true"), "IsActive");

                            //  var result1 = client.PostAsync("http://localhost:64299/api/Company/Add", content).Result;
                            var result = webServices.PostMultiPart(content, "AWFCompany/Update", true);
                            if (result.StatusCode == System.Net.HttpStatusCode.Accepted)
                            {
                                var companyViewModel = new CompanyViewModel();
                                companyViewModel = (new JavaScriptSerializer().Deserialize <CompanyViewModel>(result.Data.ToString()));

                                var userCompanyViewModel2 = Session["userCompanyViewModel"] as UserCompanyViewModel;

                                userCompanyViewModel2.LogoUrl     = companyViewModel.LogoUrl;
                                userCompanyViewModel2.CompanyName = companyViewModel.Name;

                                Session["userCompanyViewModel"] = userCompanyViewModel2;
                                Session["CompanyId"]            = companyViewModel.Id;
                                Session["UserId"] = companyViewModel.CreatedBy;

                                return(RedirectToAction(nameof(AdminCompanyInformation), new { companyViewModel.Id }));
                            }
                            else
                            {
                                ViewBag.Message = "Failed";

                                return(View("Edit", companyViewModel));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 8
0
        public ActionResult Create(CompnayModel compnayModel, HttpPostedFileBase LogoUrl)
        {
            try
            {
                if (Request.Files.Count > 0)
                {
                    var file = LogoUrl;

                    using (HttpClient client = new HttpClient())
                    {
                        using (var content = new MultipartFormDataContent())
                        {
                            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("Name"), "Name");
                            content.Add(new StringContent("street Data"), "Street");
                            string UserId = Session["UserId"].ToString();
                            content.Add(new StringContent(UserId), "CreatedBy");
                            content.Add(new StringContent(compnayModel.Postcode == null ? "" : compnayModel.Postcode), "Postcode");
                            content.Add(new StringContent(compnayModel.City == null ? "" : compnayModel.City), "City");
                            content.Add(new StringContent(compnayModel.Address == null ? "" : compnayModel.Address), "Address");
                            content.Add(new StringContent(compnayModel.State == null ? "" : compnayModel.State), "State");
                            content.Add(new StringContent(compnayModel.Country == null ? "" : compnayModel.Country), "Country");
                            content.Add(new StringContent(compnayModel.Cell == null ? "" : compnayModel.Cell), "Cell");
                            content.Add(new StringContent(compnayModel.Phone == null ? "" : compnayModel.Phone), "Phone");
                            content.Add(new StringContent(compnayModel.Email == null ? "" : compnayModel.Email), "Email");
                            content.Add(new StringContent(compnayModel.Web == null ? "" : compnayModel.Web), "Web");
                            content.Add(new StringContent(compnayModel.TRN == null ? "" : compnayModel.TRN), "TRN");
                            content.Add(new StringContent(compnayModel.Remarks == null ? "" : compnayModel.Remarks), "Remarks");
                            content.Add(new StringContent(compnayModel.OwnerRepresentaive == null ? "" : compnayModel.OwnerRepresentaive), "OwnerRepresentaive");
                            content.Add(new StringContent("true"), "IsActive");



                            //  var result1 = client.PostAsync("http://localhost:64299/api/Company/Add", content).Result;
                            var result = webServices.PostMultiPart(content, "Company/Add", true);
                            if (result.StatusCode == System.Net.HttpStatusCode.Accepted)
                            {
                                var companyViewModel = new CompanyViewModel();
                                companyViewModel = (new JavaScriptSerializer().Deserialize <CompanyViewModel>(result.Data.ToString()));


                                Session["userCompanyViewModel"] = companyViewModel;
                                Session["CompanyId"]            = companyViewModel.Id;
                                Session["UserId"] = companyViewModel.CreatedBy;

                                return(RedirectToAction("Index", "Home"));

                                ViewBag.Message = "Created";
                            }
                            else
                            {
                                ViewBag.Message = "Failed";
                            }
                        }
                    }
                }
                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 9
0
 public ActionResult Creates(CompnayModel compnayModel, HttpPostedFileBase file)
 {
     // await Creat(compnayModel,file);
     return(View());
 }
Exemplo n.º 10
0
 // GET: Company/Create
 public ActionResult Create(CompnayModel compnayModel)
 {
     return(View());
 }