Exemple #1
0
        //added control only if loged in
        public ActionResult submitShifts([ModelBinder(typeof(ShiftBinder))] shifts obj)
        {
            if (Session["id"] != null)
            {
                //chackif got this shift
                if (ModelState.IsValid)
                {
                    DateTime temp1 = DateTime.Parse(obj.startDate.Value.ToString());
                    int      temp2 = obj.userId;


                    List <shifts> result =
                        (from x in dal.WeekShifts
                         where x.startDate == temp1 && x.userId == temp2
                         select x).ToList <shifts>();


                    if (result.Count == 0)
                    {
                        dal.WeekShifts.Add(obj);
                        dal.SaveChanges();
                    }
                    else
                    {
                        ViewBag.eror = "alredy submited for the week";
                        return(View("_index"));
                    }
                }
                return(View("_index"));
            }
            return(RedirectToAction("index", "home"));
        }
Exemple #2
0
        public async Task <ActionResult> MakeAdmin(string id)
        {
            await Task.Run(() =>
            {
                if (Session["role"].ToString() == "admin")
                {
                    int serch      = int.Parse(id);
                    roles newAdmin = new roles()
                    {
                        userid = serch,
                        role   = "admin"
                    };
                    dal.roles.Add(newAdmin);
                    dal.SaveChanges();
                }
                return(Json(new { status = "success" }));
            });


            return(Content(""));
        }
 //func for adding candidate
 public ActionResult submit([ModelBinder(typeof(CandidateBinder))] Candidate obj)
 {
     if (ModelState.IsValid)
     {
         //first chack id dandidate is in the system
         List <Candidate> result = (from x in dal.Candidates
                                    where x.candidateId.Equals(obj.candidateId)
                                    select x).ToList <Candidate>();
         //first chack to find if there are dnadidates with the same name
         if (result.Count == 0)
         {
             obj.status = "new";
             dal.Candidates.Add(obj);
             dal.SaveChanges();
         }
         else
         {
             ViewBag.registerForm = "alredy has this id plz wait";
             return(View("_RegisterForm"));
         }
     }
     //if all is good
     return(RedirectToAction("index", "Home"));;
 }