Ejemplo n.º 1
0
        public bool ChangeStatus(string id, int role)
        {
            var com = database.Organization.Find(id);

            if (com.Status == true)
            {
                ChangesStatusOrgan(id, role, true);
                com.Status = false;
            }
            else
            {
                ChangesStatusOrgan(id, role, false);
                com.Status = true;
            }
            database.SaveChanges();
            return(com.Status);
        }
        public ActionResult CreateUser(Users user)
        {
            var findU = database.Users.Find(user.UserName);

            if (findU != null)
            {
                ModelState.AddModelError("", "UserName đã tồn tại");
            }
            else
            {
                var findP = database.Person.Find(user.PersonID);
                if (findP == null)
                {
                    ModelState.AddModelError("", "Sai mã xác nhận");
                }
                else
                {
                    Users tk = new Users();
                    tk.UserName = user.UserName;
                    tk.PassWord = MaHoaMd5.MD5Hash(user.PassWord);
                    tk.PersonID = user.PersonID;
                    tk.Status   = true;
                    database.Users.Add(tk);
                    database.SaveChanges();
                    ModelState.AddModelError("", "Đăng ký thành công");
                }
            }
            return(View("CreateUser"));
        }
        public ActionResult Dele(int id)
        {
            var xoa   = database.IntershipWithTask.Find(id);
            var lsort = database.IntershipWithTask.Where(x => x.InternshipID == xoa.InternshipID && x.SORT > xoa.SORT).ToList();

            foreach (var item in lsort)
            {
                item.SORT = item.SORT - 1;
                database.SaveChanges();
            }
            int count = database.IntershipWithTask.Count();
            var f     = database.IntershipWithTask.Find(count);

            xoa.InternshipID = f.InternshipID;
            xoa.TaskID       = f.TaskID;
            xoa.SORT         = f.SORT;
            database.IntershipWithTask.Remove(f);
            database.SaveChanges();
            Session["InternshipID"] = xoa.InternshipID;
            var tk = Convert.ToInt32(Session["InternshipID"]);

            return(RedirectToAction("Index", new { id = tk }));
        }
Ejemplo n.º 4
0
 public bool CreateQ(Question question)
 {
     try
     {
         Question q     = new Question();
         int      count = database.Question.Count();
         q.QuestionID = count + 1;
         q.Content    = question.Content;
         q.Answer     = question.Answer;
         q.A          = question.A;
         q.B          = question.B;
         q.C          = question.C;
         q.D          = question.D;
         q.TaskID     = question.TaskID;
         database.Question.Add(q);
         database.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 5
0
 public bool extension(string id, int val)
 {
     try
     {
         var model = database.Organization.Find(id);
         if (model.Status == true)
         {
             model.ExpiryDate += +val;
         }
         else
         {
             model.StartDay   = DateTime.Now;
             model.ExpiryDate = val;
             model.SendEmail  = false;
             new Share().ChangeStatus(id, 3);
         }
         database.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        public bool ChangeStatusLeader(string id)
        {
            var com = database.Users.SingleOrDefault(x => x.PersonID == id);

            if (com.Status == true)
            {
                com.Status = false;
                ChangeStatusInternShip(id, false);
            }
            else
            {
                com.Status = true;
                ChangeStatusInternShip(id, true);
            }
            database.SaveChanges();
            return(com.Status);
        }
Ejemplo n.º 7
0
 public bool UpdateAnswer(string id, int answer, int task)
 {
     try
     {
         TestResults testResults = new TestResults();
         testResults.ID       = database.TestResults.Count() + 1;
         testResults.PersonID = id;
         testResults.TaskID   = task;
         testResults.Answer   = answer;
         database.TestResults.Add(testResults);
         var model = database.Intern.Find(id);
         model.Result = model.Result + 1;
         database.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 public bool AddTask(List <int> listTask, int id)
 {
     try
     {
         foreach (var i in listTask)
         {
             IntershipWithTask addTask = new IntershipWithTask();
             var count = database.IntershipWithTask.Count();
             addTask.ID           = count + 1;
             addTask.InternshipID = id;
             addTask.TaskID       = i;
             var sort = database.IntershipWithTask.Where(x => x.InternshipID == id).Count();
             addTask.SORT = sort + 1;
             database.IntershipWithTask.Add(addTask);
             database.SaveChanges();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 public ActionResult Edit(InternDatabase intern)
 {
     if (ModelState.IsValid)
     {
         var model = database.Person.Find(intern.PersonID);
         model.PersonID  = intern.PersonID;
         model.LastName  = intern.LastName;
         model.FirstName = intern.FirstName;
         model.Birthday  = intern.Birthday;
         model.Gender    = intern.Gender;
         model.Address   = intern.Address;
         model.Phone     = intern.Phone;
         model.Email     = intern.Email;
         model.Image     = intern.Image;
         model.CompanyID = intern.CompanyID;
         var model1 = database.Intern.Find(intern.PersonID);
         model1.StudentCode = intern.StudentCode;
         database.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 10
0
 public bool Create(Organization organi, int roleId)
 {
     try
     {
         Organization organ = new Organization();
         Share        share = new Share();
         string       comID;
         do
         {
             comID = new Share().RandomText();
         } while (new CompanyAndSchool().FindOrgan(comID) == false);
         organ.ID         = comID;
         organ.Name       = organi.Name;
         organ.Address    = organi.Address;
         organ.Phone      = organi.Phone;
         organ.Fax        = organi.Fax;
         organ.Image      = organi.Image;
         organ.Logo       = organi.Logo;
         organ.Note       = organi.Note;
         organ.Email      = organi.Email;
         organ.StartDay   = DateTime.Now;
         organ.ExpiryDate = 1;
         organ.Status     = true;
         organ.SendEmail  = false;
         database.Organization.Add(organ);
         database.SaveChanges();
         var model = database.Organization.Find(comID);
         if (model == null)
         {
             return(false);
         }
         else
         {
             string personID;
             do
             {
                 personID = share.RandomText();
             } while (personID == comID && FindPerson(personID) == false);
             if (roleId == 2)
             {
                 if (share.insertPerson(personID, comID, null, 2))
                 {
                     database.Person.Find(personID).Email = organi.Email;
                     database.SaveChanges();
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }
             else
             {
                 if (share.insertPerson(personID, null, comID, 3))
                 {
                     database.Person.Find(personID).Email = organi.Email;
                     database.SaveChanges();
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }
         }
     }
     catch
     {
         return(false);
     }
 }