public ActionResult Index(Admin login)
        {
            if (ModelState.IsValid)
            {
                Admin user = db.Admins.FirstOrDefault(u => u.Email == login.Email);
                if (user != null)
                {
                    if (Crypto.VerifyHashedPassword(user.Password, login.Password))
                    {
                        var g = Guid.NewGuid().ToString();
                        user.Token = g;
                        db.SaveChanges();

                        Response.Cookies["cookie"].Value   = user.Token;
                        Response.Cookies["cookie"].Expires = DateTime.Now.AddDays(1);
                        return(RedirectToAction("index", "dashboard"));
                    }
                }
                else
                {
                    ModelState.AddModelError("Summary", "E-mail or password is incorrect");
                }
            }
            return(View(login));
        }
Пример #2
0
        public ActionResult Create(Project project, List <HttpPostedFileBase> Photos, string[] Technologies)
        {
            db.Projects.Add(project);
            db.SaveChanges();
            List <TechnologyProject> TechnologyProjectss = new List <TechnologyProject>();

            foreach (var tech in Technologies)
            {
                TechnologyProject technologyProject = new TechnologyProject();
                technologyProject.ProjectId  = project.Id;
                technologyProject.Technology = tech;
                TechnologyProjectss.Add(technologyProject);
            }
            db.TechnologyProjects.AddRange(TechnologyProjectss);

            foreach (var photos in Photos)
            {
                string filename = DateTime.Now.ToString("yyyyMMddHHmmss") + photos.FileName.Replace(" ", "_");
                string path     = System.IO.Path.Combine(Server.MapPath("~/Upload"), filename);
                photos.SaveAs(path);
                Photo photo = new Photo();
                photo.PhotoName = filename;
                photo.ProjectId = project.Id;
                db.Photos.Add(photo);
            }
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #3
0
        public ActionResult Edit(Info info, HttpPostedFileBase ProfilePhoto, HttpPostedFileBase BgPhoto)
        {
            Info TheInfo = db.Infos.FirstOrDefault(f => f.Id == info.Id);

            if (TheInfo != null)
            {
                if (ProfilePhoto != null)
                {
                    string filePath = Server.MapPath("~/Upload/" + TheInfo.ProfilePhoto);
                    if (System.IO.File.Exists(filePath))
                    {
                        System.IO.File.Delete(filePath);
                    }

                    string filename = DateTime.Now.ToString("yyyyMMddHHmmss") + ProfilePhoto.FileName.Replace(" ", "_");
                    string path     = System.IO.Path.Combine(Server.MapPath("~/Upload"), filename);

                    ProfilePhoto.SaveAs(path);
                    TheInfo.ProfilePhoto = filename;
                }

                if (BgPhoto != null)
                {
                    string bgpath = Server.MapPath("~/Upload/" + TheInfo.BgPhoto);
                    if (System.IO.File.Exists(bgpath))
                    {
                        System.IO.File.Delete(bgpath);
                    }

                    string bgfilename = DateTime.Now.ToString("yyyyMMddHHmmss") + BgPhoto.FileName.Replace(" ", "_");
                    string path       = System.IO.Path.Combine(Server.MapPath("~/Upload"), bgfilename);

                    BgPhoto.SaveAs(path);
                    TheInfo.BgPhoto = bgfilename;
                }

                TheInfo.Name        = info.Name;
                TheInfo.TitleFirst  = info.TitleFirst;
                TheInfo.TitleSecond = info.TitleSecond;
                TheInfo.TitleThird  = info.TitleThird;
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Пример #4
0
        public ActionResult Edit(About about)
        {
            About TheAbout = db.Abouts.Where(f => f.Id == about.Id).FirstOrDefault();

            if (TheAbout != null)
            {
                TheAbout.Title       = about.Title;
                TheAbout.Description = about.Description;
                TheAbout.Birthday    = about.Birthday;
                TheAbout.Residence   = about.Residence;
                TheAbout.Email       = about.Email;
                TheAbout.Phone       = about.Phone;
                TheAbout.Behance     = about.Behance;
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
 public ActionResult Create(Education education)
 {
     db.Educations.Add(education);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Пример #6
0
 public ActionResult Create(Skill skill)
 {
     db.Skills.Add(skill);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Пример #7
0
 public ActionResult Create(Service services)
 {
     db.Services.Add(services);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Пример #8
0
 public ActionResult Create(Experience experience)
 {
     db.Experiences.Add(experience);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Пример #9
0
 public ActionResult Create(Fact fact)
 {
     db.Facts.Add(fact);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Пример #10
0
 public ActionResult Create(Category category)
 {
     db.Categories.Add(category);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }