예제 #1
0
        public ActionResult ChangePassword(Organisation organisation)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string encryptPass = SHA512Manager.EncryptSHA512(organisation.Password);

                    int representativeID = (int)Session["RepresentativeID"];
                    int organisationID = (int)Session["OrganisationID"];

                    var company = db.CompaniesESG.Where(c => c.ID == organisationID).SingleOrDefault();
                    var representativeSamePass = company.Representatives.Where(r => r.Password == encryptPass).SingleOrDefault();

                    if (representativeSamePass != null)
                    {
                        TempData["samePassError"] = "V systému se již nachází zástupce této organizace se stejným heslem.";
                        return RedirectToAction("Details");
                    }

                    var representative = db.RepresentativesESG.Where(r => r.ID == representativeID).SingleOrDefault();

                    representative.Password = encryptPass;
                    representative.ConfirmPassword = encryptPass;

                    db.Entry(representative).State = EntityState.Modified;
                    db.SaveChanges();

                    return RedirectToAction("Details", "Organisation");
                }
            }
            catch (DataException)
            {
                //Log the error (add a variable name after DataException)
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }
            return View(organisation);
        }
예제 #2
0
        public ActionResult Registration(Organisation organisation)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var foundOrganisation = db.CompaniesESG.Where(o => o.Ico == organisation.Ico).SingleOrDefault();

                    if (foundOrganisation != null)
                    {
                        ViewData["sameIcoOrganisation"] = "V systému se již nachází organizace se stejným IČO.";
                        ViewData["logOnView"] = "logOnView";
                        PopulateSectorsDropDownList(organisation.SectorID);
                        return View(organisation);
                    }

                    foundOrganisation = db.CompaniesESG.Where(o => o.Dic == organisation.Dic).SingleOrDefault();

                    if (foundOrganisation != null)
                    {
                        ViewData["sameDicOrganisation"] = "V systému se již nachází organizace se stejným DIČ.";
                        ViewData["logOnView"] = "logOnView";
                        PopulateSectorsDropDownList(organisation.SectorID);
                        return View(organisation);
                    }

                    string encryptPassword = SHA512Manager.EncryptSHA512(organisation.Password);

                    Company company = new Company();
                    company.Address = organisation.Address;
                    company.Created = DateTime.Now;
                    company.Description = organisation.Description;
                    company.Dic = organisation.Dic.ToUpper();
                    company.Email = organisation.Email;
                    company.Ico = organisation.Ico;
                    company.Name = organisation.Name;
                    company.SectorID = organisation.SectorID;
                    company.Telephone = organisation.Telephone;
                    company.Webpage = organisation.Webpage;

                    db.CompaniesESG.Add(company);

                    db.SaveChanges();

                    Representative representative = new Representative();

                    representative.Degree = organisation.Degree;
                    representative.Firstname = organisation.Firstname;
                    representative.IdNumber = organisation.IdNumber;
                    representative.CompanyID = company.ID;
                    representative.Password = encryptPassword;
                    representative.ConfirmPassword = encryptPassword;
                    representative.PersonalEmail = organisation.PersonalEmail;
                    representative.PersonalTelephone = organisation.PersonalTelephone;
                    representative.Surname = organisation.Surname;
                    representative.Active = true;

                    db.RepresentativesESG.Add(representative);

                    db.SaveChanges();

                    XBRLTransformer.CreateTaxonomy(company.ID);

                    Session["OrganisationID"] = company.ID;
                    Session["RepresentativeID"] = representative.ID;
                    Session["OrganisationName"] = company.Name;

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

            }
            catch (System.Data.DataException)
            {
                //Log the error (add a variable name after DataException)
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }

            PopulateSectorsDropDownList(organisation.SectorID);
            ViewData["logOnView"] = "logOnView";
            return View(organisation);
        }
예제 #3
0
        /// <summary>
        /// Displays details of selected organisation.
        /// </summary>
        /// /// <param name="id">id of selected organisation</param>
        public ActionResult OrganisationDetails(int id)
        {
            var company = db.CompaniesESG.Where(o => o.ID == id).SingleOrDefault();
            var representative = company.Representatives.Where(r => r.Active).SingleOrDefault();

            Organisation org = new Organisation();
            org.ID = company.ID;
            org.Address = company.Address;
            org.ConfirmPassword = representative.ConfirmPassword;
            org.Created = company.Created;
            org.Degree = representative.Degree;
            org.Description = company.Description;
            org.Dic = company.Dic;
            org.Email = company.Email;
            org.Firstname = representative.Firstname;
            org.Ico = company.Ico;
            org.IdNumber = representative.IdNumber;
            org.Name = company.Name;
            org.Password = representative.Password;
            org.PersonalEmail = representative.PersonalEmail;
            org.PersonalTelephone = representative.PersonalTelephone;
            org.Reports = company.Reports;
            org.SectorID = company.SectorID;
            org.Surname = representative.Surname;
            org.Telephone = company.Telephone;
            org.Webpage = company.Webpage;

            return View(org);
        }
예제 #4
0
        public ActionResult Details(Organisation organisation)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var company = db.CompaniesESG.Where(c => c.ID == organisation.ID).SingleOrDefault();
                    company.Address = organisation.Address;
                    company.Created = organisation.Created;
                    company.Description = organisation.Description;
                    company.Dic = organisation.Dic;
                    company.Email = organisation.Email;
                    company.Ico = organisation.Ico;
                    company.Name = organisation.Name;
                    company.SectorID = organisation.SectorID;
                    company.Telephone = organisation.Telephone;
                    company.Webpage = organisation.Webpage;

                    db.Entry(company).State = EntityState.Modified;
                    db.SaveChanges();

                    int representativeID = (int)Session["RepresentativeID"];

                    var representative = db.RepresentativesESG.Where(r => r.ID == representativeID).SingleOrDefault();
                    representative.ConfirmPassword = organisation.ConfirmPassword;
                    representative.Degree = organisation.Degree;
                    representative.Firstname = organisation.Firstname;
                    representative.IdNumber = organisation.IdNumber;
                    representative.Password = organisation.Password;
                    representative.PersonalEmail = organisation.PersonalEmail;
                    representative.PersonalTelephone = organisation.PersonalTelephone;
                    representative.Surname = organisation.Surname;

                    db.Entry(representative).State = EntityState.Modified;
                    db.SaveChanges();

                    XBRLTransformer.CreateTaxonomy(organisation.ID);

                    return RedirectToAction("Details", "Organisation");
                }
            }
            catch (DataException)
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }
            return View(organisation);
        }
예제 #5
0
        /// <summary>
        /// Desplays details of logged organisation
        /// </summary>
        public ActionResult Details()
        {
            if (Session["OrganisationID"] == null)
            {
                TempData["accessError"] = "Vaše session vypršela, nebo nejste přihlášen.";
                return RedirectToAction("LogOn", "Organisation");
            }

            int organisationID = (int) Session["OrganisationID"];
            int representativeID = (int)Session["RepresentativeID"];
            //var model = db.Organisations.Where(o => o.ID == organisationID).SingleOrDefault();
            //model.ConfirmPassword = model.Password;

            var co = db.CompaniesESG.Where(c => c.ID == organisationID).SingleOrDefault();
            var re = co.Representatives.Where(r => r.ID == representativeID).SingleOrDefault();

            Organisation o = new Organisation();
            o.ID = co.ID;
            o.Address = co.Address;
            o.ConfirmPassword = re.Password;
            o.Created = co.Created;
            o.Degree = re.Degree;
            o.Description = co.Description;
            o.Dic = co.Dic;
            o.Email = co.Email;
            o.Firstname = re.Firstname;
            o.Ico = co.Ico;
            o.IdNumber = re.IdNumber;
            o.Name = co.Name;
            o.Password = re.Password;
            o.PersonalEmail = re.PersonalEmail;
            o.PersonalTelephone = re.PersonalTelephone;
            o.SectorID = co.SectorID;
            o.Surname = re.Surname;
            o.Telephone = co.Telephone;
            o.Webpage = co.Webpage;

            return View(o);
        }