Example #1
0
        public async Task <IActionResult> Details()
        {
            var TrainingCompany = await _trainingcompany.Entity.GetAll().AsNoTracking().FirstOrDefaultAsync();

            var Contact = await _contact.Entity.GetAll().AsNoTracking().FirstOrDefaultAsync();

            var CompanyInfoViewModel = new CompanyInfoViewModel
            {
                TrainingCompany = TrainingCompany,
                Contact         = Contact
            };

            return(View(CompanyInfoViewModel));
        }
        public ActionResult Create(CompanyInfoViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // TODO: Add insert logic here
                    viewModel.Fax      = viewModel.Fax ?? String.Empty;
                    viewModel.Mobile   = viewModel.Mobile ?? String.Empty;
                    viewModel.Website  = viewModel.Website ?? String.Empty;
                    viewModel.Logo     = viewModel.Logo ?? String.Empty;
                    viewModel.Facebook = viewModel.Facebook ?? String.Empty;
                    string fileName = "";
                    if (viewModel.filePosted != null)
                    {
                        var checkextension = Path.GetExtension(viewModel.filePosted.FileName).ToLower();
                        if (viewModel.filePosted != null && viewModel.filePosted.ContentLength > 0)
                        {
                            if (allowedExtensions.Contains(checkextension))
                            {
                                fileName = MediaHelper.SaveImageFile(viewModel.filePosted, Constants.hethong, Extentions.ToUnsignLinkString(viewModel.CompanyName));
                            }
                            else
                            {
                                ModelState.AddModelError("filePosted", "File không hợp lệ");
                                return(View(viewModel));
                            }
                        }
                    }
                    else
                    {
                        fileName = Constants.NOIMAGE;
                    }

                    viewModel.Logo = fileName;
                    _iCompanyInfoService.DeleteAccount();
                    _iCompanyInfoService.InsertInfo(viewModel);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View("Index", viewModel));
                }
            }
            catch
            {
                return(View("Index", viewModel));
            }
        }
Example #3
0
        //[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult SaveMyCompanyInfo(CompanyInfoViewModel model, FormCollection collection)
        {
            //var franchiseID = Convert.ToInt32(collection["FranchiseID"]);
            var franchiseID = model.FranchiseID;

            var companyInfo = (from e in DB.tbl_Franchise
                               join o in DB.tbl_Franchise_Owner on e.OwnerID equals o.OwnerID
                               where e.FranchiseID == franchiseID
                               select e).FirstOrDefault();

            var ownerInfo = (from e in DB.tbl_Franchise_Owner where e.OwnerID == companyInfo.OwnerID select e).FirstOrDefault();

            ownerInfo.OwnerName        = model.OwnerName;
            companyInfo.LegalName      = model.LegalName;
            companyInfo.LegalAddress   = model.LegalAddress;
            companyInfo.LegalCity      = model.LegalCity;
            companyInfo.LegalState     = model.LegalState;
            companyInfo.LegalPostal    = model.LegalPostal;
            companyInfo.LegalCountryID = model.LegalCountryID;

            companyInfo.ShipName      = model.ShipName;
            companyInfo.ShipCompany   = model.ShipCompany;
            companyInfo.ShipAddress   = model.ShipAddress;
            companyInfo.ShipCity      = model.ShipCity;
            companyInfo.ShipState     = model.ShipState;
            companyInfo.ShipPostal    = model.ShipPostal;
            companyInfo.ShipCountryID = model.ShipCountryID;

            companyInfo.MailName      = model.MailName;
            companyInfo.MailCompany   = model.MailCompany;
            companyInfo.MailAddress   = model.MailAddress;
            companyInfo.MailCity      = model.MailCity;
            companyInfo.MailState     = model.MailState;
            companyInfo.MailPostal    = model.MailPostal;
            companyInfo.MailCountryID = model.MailCountryID;

            companyInfo.OfficeName      = model.OfficeName;
            companyInfo.OfficeCompany   = model.OfficeCompany;
            companyInfo.OfficeAddress   = model.OfficeAddress;
            companyInfo.OfficeCity      = model.OfficeCity;
            companyInfo.OfficeState     = model.OfficeState;
            companyInfo.OfficePostal    = model.OfficePostal;
            companyInfo.OfficeCountryID = model.OfficeCountryID;

            DB.SaveChanges();

            return(RedirectToAction("MyCompanyInfo"));
        }
Example #4
0
        public ActionResult MyCompanyInfo(FormCollection collection)
        {
            //var phoneType = (from p in DB.tbl_PhoneType select p);
            //ViewBag.PhoneType = phoneType;
            //var ddlcountry = (from e in DB.tbl_Franchise_Country select e).ToList();
            //ViewBag.ddlCountry = ddlcountry;
            //var ddlconcept = (from c in DB.tbl_Concept select c).ToList();
            //ViewBag.ddlConcept = ddlconcept;
            //var ddlstatus = (from s in DB.tbl_Franchise_Status select s).ToList();
            //ViewBag.ddlStatus = ddlstatus;
            //var ddlfranchiseetype = (from c in DB.tbl_Franchise_Type select c).ToList();
            //ViewBag.ddlFranchiseeType = ddlfranchiseetype;
            //var ddldivision = (from d in DB.tbl_Franchise_Division select d).ToList();
            //ViewBag.ddlRegion = ddldivision;

            // Trying to get current franchise id from the UserInfo object.
            var franchiseID = UserInfo.CurrentFranchise.FranchiseID;

            // Trying to get company information when this view gets called.

            var companyInfo = (from f in DB.tbl_Franchise
                               join fo in DB.tbl_Franchise_Owner on f.OwnerID equals fo.OwnerID
                               where f.FranchiseID == franchiseID
                               select new { Franchise = f, FranchiseOwner = fo }).FirstOrDefault();

            var phoneTypeList = (from p in DB.tbl_PhoneType select p);
            var countryList   = (from c in DB.tbl_Franchise_Country select c).ToList();

            countryList.Insert(0, new tbl_Franchise_Country {
                CountryID = 0, Country = "Select Country"
            });

            var model = new CompanyInfoViewModel
            {
                PhoneType   = new SelectList(phoneTypeList, "PhoneTypeID", "PhoneType"),
                CountryList = new SelectList(countryList, "CountryID", "Country")
            };

            return(View(model));
        }
Example #5
0
        public IndexContractViewModel(JobContract Contract)
        {
            var ce       = Contract.CompanyEmployees.First();
            var company  = ce.Company;
            var region   = company.Entity.GetCurrentRegion();
            var country  = region.Country;
            var currency = country.Currency;

            Info = new CompanyInfoViewModel(company);

            CountryName   = country.Entity.Name;
            RegionName    = region.Name;
            ContractID    = Contract.ID;
            EmployeeName  = ce.Citizen.Entity.Name;
            MinimumHP     = Contract.MinHP;
            MinimalSalary = (double)Contract.MinSalary;
            CompanyName   = company.Entity.Name;
            StartDay      = ce.StartDay;
            RemainingTime = Contract.Length;
            EndDay        = GameHelper.CurrentDay + RemainingTime;
            SalarySymbol  = currency.Symbol;
            SigneeName    = Contract.Entity.Name;
        }
Example #6
0
        /// <summary>
        /// update Company Information
        /// </summary>
        /// <param name="companyUpdateInfo"></param>
        /// <param name="errorMsg"></param>
        /// <returns></returns>
        public bool  UpdateCompanyInfo(CompanyInfoViewModel companyUpdateInfo, out string errorMsg, HttpPostedFileBase UploadFile)
        {
            errorMsg = "";


            if (companyUpdateInfo.Address.CountryID != 1)
            {
                errorMsg = "PAF Is Only Used For UK, So please Select a Country As a UK..!! ";
                return(false);
            }

            try
            {
                var companyDB = db.Common_HostSettings.ToList();

                companyDB.Where(x => x.HostKey.Equals("CompanyName")).Single().HostValue    = companyUpdateInfo.CompanyName;
                companyDB.Where(x => x.HostKey.Equals("EmailAddress")).Single().HostValue   = companyUpdateInfo.EmailAddress;
                companyDB.Where(x => x.HostKey.Equals("FaxNo")).Single().HostValue          = companyUpdateInfo.FaxNo;
                companyDB.Where(x => x.HostKey.Equals("RegistrationNo")).Single().HostValue = companyUpdateInfo.RegistrationNo;
                companyDB.Where(x => x.HostKey.Equals("TelephoneNo")).Single().HostValue    = companyUpdateInfo.TelephoneNo.ToString();
                companyDB.Where(x => x.HostKey.Equals("VATNo")).Single().HostValue          = companyUpdateInfo.VATNo;
                companyDB.Where(x => x.HostKey.Equals("Website")).Single().HostValue        = companyUpdateInfo.Website;
                companyDB.Where(x => x.HostKey.Equals("DateFormat")).Single().HostValue     = CommonDate().Where(x => x.DateFormatID.Equals(companyUpdateInfo.DateFormatID)).Select(x => x.DateFormat).Single();
                companyDB.Where(x => x.HostKey.Equals("Currency")).Single().HostValue       = CommonCurrency().Where(x => x.CurrencyID.Equals(companyUpdateInfo.CurrencyID)).Select(x => x.Currency).Single();
                companyDB.Where(x => x.HostKey.Equals("TimeZone")).Single().HostValue       = GetTimeZone().Where(x => x.Id.Equals(companyUpdateInfo.TimeZoneID)).Select(x => x.DisplayName).Single();
                companyDB.Where(x => x.HostKey.Equals("TimeFormat")).Single().HostValue     = CommonTime().Where(x => x.TimeID.Equals(companyUpdateInfo.TimeID)).Select(x => x.TimeFormat).Single();
                if (companyUpdateInfo.Address.Postcode != null)
                {
                    companyUpdateInfo.Address.AddressID = addressBL.CheckAddress(companyUpdateInfo.Address);
                    companyUpdateInfo.AddressID         = companyUpdateInfo.Address.AddressID;
                    if (companyUpdateInfo.Address.AddressID == 0)
                    {
                        errorMsg = "Company Details is Not Updated.......!";
                        return(false);
                    }
                    companyDB.Where(x => x.HostKey.Equals("AddressID")).Single().HostValue = companyUpdateInfo.Address.AddressID.ToString();
                }


                if (UploadFile != null)
                {
                    if (UploadFile.ContentType == "image/jpeg" || UploadFile.ContentType == "image/png" || UploadFile.ContentType == "image/gif")
                    {
                        Common_HostLogo ComLogo = db.Common_HostLogo.SingleOrDefault(x => x.LogoID == 8);
                        ComLogo.HostLogoContentType = UploadFile.ContentType;
                        ComLogo.HostLogoContent     = ConvertToBytes(UploadFile);

                        db.SaveChanges();
                        errorMsg = "Successfully Saved.......!";
                    }
                    else
                    {
                        errorMsg = "ImageType Should Be 'jpeg' Or 'png' Or 'gif' ";
                        return(false);
                    }
                }
                else
                {
                    Common_HostLogo CmHostlogo = new Common_HostLogo();
                    CmHostlogo.HostLogoContentType = null;
                    CmHostlogo.HostLogoContent     = null;

                    db.SaveChanges();
                    errorMsg = "SuccessFully Saved.......!";
                }
                return(true);
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
                return(false);
            }
        }
Example #7
0
        public virtual async Task <IActionResult> OnGetAsync()
        {
            CompanyInfo = new CompanyInfoViewModel();

            return(Page());
        }
Example #8
0
        public async Task <ActionResult> Edit(CompanyInfoViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var TrainingCompany = await _trainingcompany.Entity.GetAll().FirstOrDefaultAsync();

                    if (TrainingCompany != null)
                    {
                        TrainingCompany.Name           = model.TrainingCompany.Name;
                        TrainingCompany.Specialization = model.TrainingCompany.Specialization;
                        TrainingCompany.Description    = model.TrainingCompany.Description;
                        TrainingCompany.CreatedDate    = model.TrainingCompany.CreatedDate;
                        TrainingCompany.ModifiedDate   = DateTime.Now;
                        if (model.File != null)
                        {
                            TrainingCompany.Picture = FileToByte(model.File);
                        }
                        _trainingcompany.Entity.Update(TrainingCompany);
                        await _trainingcompany.SaveAsync();
                    }
                    else
                    {
                        TrainingCompany newtrainingcompany = new TrainingCompany
                        {
                            Name           = model.TrainingCompany.Name,
                            Specialization = model.TrainingCompany.Specialization,
                            Description    = model.TrainingCompany.Description,
                            CreatedDate    = DateTime.Now,
                            Picture        = FileToByte(model.File) ?? null
                        };
                        _trainingcompany.Entity.Insert(newtrainingcompany);
                        await _trainingcompany.SaveAsync();
                    }


                    var Contact = await _contact.Entity.GetAll().FirstOrDefaultAsync();

                    if (Contact != null)
                    {
                        Contact.Email        = model.Contact.Email;
                        Contact.Phone        = model.Contact.Phone;
                        Contact.Facebook     = model.Contact.Facebook;
                        Contact.Location     = model.Contact.Location;
                        Contact.CreatedDate  = model.Contact.CreatedDate;
                        Contact.ModifiedDate = DateTime.Now;
                        _contact.Entity.Update(Contact);
                        await _contact.SaveAsync();
                    }
                    else
                    {
                        //كود زايد للشرح والتوضيح
                        Contact newContact = new Contact
                        {
                            Email       = model.Contact.Email,
                            Phone       = model.Contact.Phone,
                            Facebook    = model.Contact.Facebook,
                            Location    = model.Contact.Location,
                            CreatedDate = DateTime.Now
                        };
                        _contact.Entity.Insert(newContact);
                        await _contact.SaveAsync();
                    }
                }
                catch (Exception)
                {
                    throw;
                }
                return(RedirectToAction(nameof(Details)));
            }
            return(RedirectToAction("Edit", "CompanyInfo"));
        }
        public async Task <ActionResult> CompanyInfo(CompanyInfoViewModel model)
        {
            ISiteSettings selectedSite = null;

            if (model.SiteGuid == siteManager.CurrentSite.SiteGuid)
            {
                selectedSite      = siteManager.CurrentSite;
                ViewData["Title"] = "Company Info";
            }
            else if (siteManager.CurrentSite.IsServerAdminSite)
            {
                selectedSite = await siteManager.Fetch(model.SiteGuid);

                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, "{0} - Company Info", selectedSite.SiteName);
            }

            if (selectedSite == null)
            {
                this.AlertDanger("oops something went wrong.", true);

                return(RedirectToAction("Index"));
            }

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.SiteGuid == Guid.Empty)
            {
                this.AlertDanger("oops something went wrong, site was not found.", true);

                return(RedirectToAction("Index"));
            }

            //model.SiteId = Site.SiteSettings.SiteId;
            //model.SiteGuid = Site.SiteSettings.SiteGuid;

            selectedSite.CompanyName           = model.CompanyName;
            selectedSite.CompanyStreetAddress  = model.CompanyStreetAddress;
            selectedSite.CompanyStreetAddress2 = model.CompanyStreetAddress2;
            selectedSite.CompanyLocality       = model.CompanyLocality;
            selectedSite.CompanyRegion         = model.CompanyRegion;
            selectedSite.CompanyPostalCode     = model.CompanyPostalCode;
            selectedSite.CompanyCountry        = model.CompanyCountry;
            selectedSite.CompanyPhone          = model.CompanyPhone;
            selectedSite.CompanyFax            = model.CompanyFax;
            selectedSite.CompanyPublicEmail    = model.CompanyPublicEmail;

            bool result = await siteManager.Save(selectedSite);

            if (result)
            {
                this.AlertSuccess(string.Format("Company Info for <b>{0}</b> wwas successfully updated.",
                                                selectedSite.SiteName), true);
            }


            if ((siteManager.CurrentSite.IsServerAdminSite) &&
                (siteManager.CurrentSite.SiteGuid != selectedSite.SiteGuid)
                )
            {
                return(RedirectToAction("CompanyInfo", new { siteGuid = model.SiteGuid }));
            }

            return(RedirectToAction("CompanyInfo"));
        }
        public async Task <IActionResult> CompanyInfo(
            Guid?siteGuid,
            int slp = 1)
        {
            ISiteSettings selectedSite;

            // only server admin site can edit other sites settings
            if ((siteGuid.HasValue) && (siteGuid.Value != Guid.Empty) && (siteGuid.Value != siteManager.CurrentSite.SiteGuid) && (siteManager.CurrentSite.IsServerAdminSite))
            {
                selectedSite = await siteManager.Fetch(siteGuid.Value);

                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, "{0} - Company Info", selectedSite.SiteName);
            }
            else
            {
                selectedSite      = siteManager.CurrentSite;
                ViewData["Title"] = "Company Info";
            }

            CompanyInfoViewModel model = new CompanyInfoViewModel();

            model.SiteGuid              = selectedSite.SiteGuid;
            model.SiteId                = selectedSite.SiteId;
            model.CompanyName           = selectedSite.CompanyName;
            model.CompanyStreetAddress  = selectedSite.CompanyStreetAddress;
            model.CompanyStreetAddress2 = selectedSite.CompanyStreetAddress2;
            model.CompanyLocality       = selectedSite.CompanyLocality;
            model.CompanyRegion         = selectedSite.CompanyRegion;
            model.CompanyPostalCode     = selectedSite.CompanyPostalCode;
            model.CompanyCountry        = selectedSite.CompanyCountry;
            model.CompanyPhone          = selectedSite.CompanyPhone;
            model.CompanyFax            = selectedSite.CompanyFax;
            model.CompanyPublicEmail    = selectedSite.CompanyPublicEmail;

            model.AvailableCountries.Add(new SelectListItem {
                Text = "-Please select-", Value = "Selects items"
            });
            var countries = await geoDataManager.GetAllCountries();

            Guid selectedCountryGuid = Guid.Empty;

            foreach (var country in countries)
            {
                if (country.ISOCode2 == model.CompanyCountry)
                {
                    selectedCountryGuid = country.Guid;
                }
                model.AvailableCountries.Add(new SelectListItem()
                {
                    Text  = country.Name,
                    Value = country.ISOCode2.ToString()
                });
            }

            if (selectedCountryGuid != Guid.Empty)
            {
                var states = await geoDataManager.GetGeoZonesByCountry(selectedCountryGuid);

                foreach (var state in states)
                {
                    model.AvailableStates.Add(new SelectListItem()
                    {
                        Text  = state.Name,
                        Value = state.Code
                    });
                }
            }


            return(View(model));
        }