Exemple #1
0
        public ActionResult Create([Bind(Include = "Id,Position,NumberOfPersons,Team,Head,TypeOfPayment,Amount,CurrencyType,PaymentComments,EmploymentType,CauseOfOccurrence,Duties,GoalsAndObjectives,Gender,YearsOld,FamilyStatus,Location,Education,WorkExperience,ProfessionalKnowledge,PersonalQualities,AdditionalRequirements,TechnicalInterviewsAreConducted,TheFinalDecision,ExpectedDateOfEmployment")] Vacancies vacancies)
        {
            if (ModelState.IsValid)
            {
                db.Vacancies.Add(vacancies);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(vacancies));
        }
Exemple #2
0
        public MembershipUser CreateUser(string email, string password)
        {
            MembershipUser membershipUser = GetUser(email, false);

            if (membershipUser == null)
            {
                try
                {
                    using (SwanDbEntities db = new SwanDbEntities())
                    {
                        User user = new User();
                        user.Email        = email;
                        user.Password     = Crypto.HashPassword(password);
                        user.CreationDate = DateTime.Now;

                        if (db.Roles.Find(2) != null)
                        {
                            user.RoleId = 2;
                        }

                        db.Users.Add(user);
                        db.SaveChanges();
                        membershipUser = GetUser(email, false);
                        return(membershipUser);
                    }
                }
                catch
                {
                    return(null);
                }
            }
            return(null);
        }
Exemple #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            var  db   = new SwanDbEntities();
            User user = db.Users.Find(id);

            db.Users.Remove(user);
            db.SaveChanges();
            return(RedirectToAction("ShowAllUsers", "Account"));
        }
        public ActionResult Edit(Candidate candidate, HttpPostedFileBase image = null, HttpPostedFileBase file = null)
        {
            if (ModelState.IsValid)
            {
                if (image != null)
                {
                    candidate.PhotoMimeType = image.ContentType;
                    candidate.Photo         = new byte[image.ContentLength];
                    image.InputStream.Read(candidate.Photo, 0, image.ContentLength);
                }

                if (file != null)
                {
                    candidate.AttachmentsMimeType = file.ContentType;
                    candidate.Attachments         = new byte[file.ContentLength];
                    file.InputStream.Read(candidate.Attachments, 0, file.ContentLength);
                }

                if (candidate.CandidateId == 0)
                {
                    _db.Candidate.Add(candidate);
                }
                else
                {
                    var entry = _db.Entry(candidate);
                    entry.State = EntityState.Modified;
                    if (image == null)
                    {
                        entry.Property(e => e.Photo).IsModified         = false;
                        entry.Property(e => e.PhotoMimeType).IsModified = false;
                    }
                    if (file == null)
                    {
                        entry.Property(e => e.Attachments).IsModified         = false;
                        entry.Property(e => e.AttachmentsMimeType).IsModified = false;
                    }
                }
                candidate.WhoIntroduced = _db.Users.First(u => u.Email == HttpContext.User.Identity.Name).Id;
                _db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.Vacancy = new SelectList(_db.Vacancies, "Id", "Position", candidate.Vacancy);
            return(View("Edit", candidate));
        }
Exemple #5
0
        public override void CreateRole(string roleName)
        {
            Role newRole = new Role()
            {
                Name = roleName
            };
            SwanDbEntities db = new SwanDbEntities();

            db.Roles.Add(newRole);
            db.SaveChanges();
        }
Exemple #6
0
        public ActionResult Edit([Bind(Include = "Id,Email,Password,CreationDate,RoleId")] User user)
        {
            var db = new SwanDbEntities();

            if (ModelState.IsValid)
            {
                db.Entry(user).State = EntityState.Modified;

                db.SaveChanges();
                return(RedirectToAction("ShowAllUsers", "Account"));
            }
            ViewBag.RoleId = new SelectList(db.Roles, "Id", "Name", user.RoleId);
            return(View(user));
        }