public ActionResult Create(Sick sick)
        {
            sick.Id = Guid.NewGuid();

            db.Sick.Add(sick);

            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public ActionResult Create(User user)
        {
            user.Id = Guid.NewGuid();

            db.User.Add(user);

            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
        public ActionResult Create([Bind(Include = "Id,name,decription")] Roles roles)
        {
            if (ModelState.IsValid)
            {
                db.Roles.Add(roles);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(roles));
        }
        public ActionResult Create([Bind(Include = "Id,StudentName,StudentCode")] Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(student));
        }
Esempio n. 5
0
        public ActionResult Create([Bind(Include = "Id,BookName,ISBN,DatePublish,Publisher,Author")] Book book)
        {
            if (ModelState.IsValid)
            {
                db.Books.Add(book);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(book));
        }
Esempio n. 6
0
 public IHttpActionResult post([FromBody] medical_card medical)
 {
     try
     {
         db.medical_card.Add(medical);
         db.SaveChanges();
         return(Ok(medical));
     }
     catch (Exception error)
     {
         return(InternalServerError(error));
     }
 }
Esempio n. 7
0
        public ActionResult Create([Bind(Include = "Id,BookId,StatusId,Date,StudentId")] IssueBook issueBook)
        {
            if (ModelState.IsValid)
            {
                db.IssueBooks.Add(issueBook);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BookId    = new SelectList(db.Books, "Id", "BookName", issueBook.BookId);
            ViewBag.StatusId  = new SelectList(db.Status, "Id", "Status1", issueBook.StatusId);
            ViewBag.StudentId = new SelectList(db.Students, "Id", "StudentName", issueBook.StudentId);
            return(View(issueBook));
        }
Esempio n. 8
0
 public ActionResult AssignRole(UserEvent modem)
 {
     if (ModelState.IsValid)
     {
         string             message = "";
         Database1Entities3 s       = new Database1Entities3();
         var k = s.UserEvents.Where(a => a.EmailID == modem.EmailID).FirstOrDefault();
         var v = s.UserEvents.Where(a => a.EventName == modem.EventName).FirstOrDefault();
         if (k != null && v != null)
         {
             k.Roles = modem.Roles;
             s.SaveChanges();
             ModelState.Clear();
             SendVerificationLinkEmail(modem.EmailID, modem.Roles, modem.EventName);
             message         = "User roles are successfully assigned and notified for user";
             ViewBag.Message = message;
             return(View());
         }
         else
         {
             ModelState.AddModelError("InValidEventname", "User not Registered for this event");
             return(View(modem));
         }
     }
     return(View(modem));
 }
        public ActionResult ForgotPassword(string EmailID)
        {
            //Verify Email ID
            //Generate Reset password link
            //Send Email
            string message = "";

            //  bool status = false;

            using (Database1Entities3 dc = new Database1Entities3())
            {
                var account = dc.Users.Where(a => a.EmailID == EmailID).FirstOrDefault();
                if (account != null)
                {
                    //Send email for reset password
                    string resetCode = Guid.NewGuid().ToString();
                    SendVerificationLinkEmail(account.EmailID, resetCode);
                    account.ResetCode = resetCode;
                    dc.Configuration.ValidateOnSaveEnabled = false;
                    dc.SaveChanges();
                    message = "Reset password link has been sent to your Email id.";
                }
                else
                {
                    message = "Account not found";
                }
            }
            ViewBag.Message = message;
            return(View());
        }
Esempio n. 10
0
        public ActionResult Save(Emp employee)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (Database1Entities3 dc = new Database1Entities3())
                {
                    if (employee.Id > 0)
                    {
                        //Edit
                        var v = dc.Emps.Where(a => a.Id == employee.Id).FirstOrDefault();
                        if (v != null)
                        {
                            v.Id         = employee.Id;
                            v.Gender     = employee.Gender;
                            v.Department = employee.Department;
                            v.City       = employee.City;
                        }
                    }
                    else
                    {
                        //Save
                        dc.Emps.Add(employee);
                    }
                    dc.SaveChanges();
                    status = true;
                    return(View());
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
        public ActionResult ResetPassword(ResetPassword model)
        {
            var message = "";

            if (ModelState.IsValid)
            {
                using (Database1Entities3 db = new Database1Entities3())
                {
                    var user = db.Users.Where(a => a.ResetCode == model.ResetCode).FirstOrDefault();
                    if (user != null)
                    {
                        user.Password  = Crypto.Hash(model.NewPassword);
                        user.ResetCode = "";
                        db.Configuration.ValidateOnSaveEnabled = false;
                        db.SaveChanges();
                        message = "Your Password was Updated Successfully";
                    }
                }
            }
            else
            {
                message = "Something Invalid";
            }

            ViewBag.Message = message;
            return(View(model));
        }
Esempio n. 12
0
        public ActionResult EditEvent(string EventName, String Region, String Description, String Date, String City, String TypeofEvent, String NumberOfOfficialsNeeded)
        {
            if (ModelState.IsValid)
            {
                string             message = "";
                Database1Entities3 edit    = new Database1Entities3();
                Addevent           p       = edit.Addevents.Find(EventName);

                edit.Configuration.ValidateOnSaveEnabled = false;
                p.Region                  = Region;
                p.Description             = Description;
                p.Date                    = Date;
                p.City                    = City;
                p.TypeofEvent             = TypeofEvent;
                p.NumberOfOfficialsNeeded = NumberOfOfficialsNeeded;
                edit.SaveChanges();
                message         = "Event Edited Successfully";
                ViewBag.Message = message;
                return(View());
            }
            else
            {
                return(View());
            }
        }
Esempio n. 13
0
        public ActionResult AddEvents(Addevent modem)
        {
            string             message = "";
            Database1Entities3 s       = new Database1Entities3();

            if (ModelState.IsValid)
            {
                var isExist = IsEventNameExist(modem.EventName);
                if (isExist)
                {
                    ModelState.AddModelError("EventNameExist", "Event Name already exist");
                    return(View(modem));
                }

                s.Addevents.Add(modem);
                s.SaveChanges();

                message         = "New Event Added Successfully";
                ViewBag.Message = message;
                return(View());
                // return RedirectToAction("AdminEvents", "Events");
            }
            else
            {
                return(View());
            }
        }
Esempio n. 14
0
        public ActionResult contact(CONTACT data)
        {
            information();
            data.CREATED_DATE = DateTime.Now;
            var cont = db.CONTACTs.Add(data);

            db.SaveChanges();
            return(View());
        }
Esempio n. 15
0
        public ActionResult delete(string NewsTitle)
        {
            Database1Entities3 db1 = new Database1Entities3();
            News del = db1.News.FirstOrDefault(X => X.NewsTitle == NewsTitle);

            db1.News.Remove(del);

            db1.SaveChanges();

            return(View());
        }
Esempio n. 16
0
        public ActionResult AddNews(News modem)
        {
            Database1Entities3 k = new Database1Entities3();

            if (ModelState.IsValid)
            {
                k.News.Add(modem);
                k.SaveChanges();


                return(RedirectToAction("AdminNews", "News"));
            }
            else
            {
                return(View());
            }
        }
Esempio n. 17
0
        public ActionResult DeleteEmployee(int id)
        {
            bool status = false;

            using (Database1Entities3 db = new Database1Entities3())
            {
                var v = db.Emps.Where(a => a.Id == id).FirstOrDefault();
                if (v != null)
                {
                    db.Emps.Remove(v);
                    db.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Esempio n. 18
0
        public ActionResult NonSkatting([Bind(Exclude = "Password,ConfirmPassword")] string NSkRoles, string NSkExperience, string NSkCertificationLevels, string NSkAdditionalSkills)

        {
            string email   = @HttpContext.User.Identity.Name;
            string message = "";

            using (Database1Entities3 dc = new Database1Entities3())
            {
                User edit = dc.Users.Find(email);
                edit.NSkRoles               = NSkRoles;
                edit.NSkExperience          = NSkExperience;
                edit.NSkCertificationLevels = NSkCertificationLevels;
                edit.NSkAdditionalSkills    = NSkAdditionalSkills;

                dc.Configuration.ValidateOnSaveEnabled = false;
                dc.SaveChanges();
                message         = "Your details are updated successfully";
                ViewBag.Message = message;
                return(View());
            }
        }
        public ActionResult VerifyAccount(string id)
        {
            bool Status = false;

            using (Database1Entities3 dc = new Database1Entities3())
            {
                dc.Configuration.ValidateOnSaveEnabled = false;
                var v = dc.Users.Where(a => a.ActivationCode == new Guid(id)).FirstOrDefault();
                if (v != null)
                {
                    v.IsEmailVerified = true;
                    dc.SaveChanges();
                    Status = true;
                }
                else
                {
                    ViewBag.Message = "Invalid Request";
                }
            }
            ViewBag.Status = Status;
            return(View());
        }
Esempio n. 20
0
        public ActionResult PersonalDetails([Bind(Exclude = "Password,ConfirmPassword")] string FirstName, string LastName, string Street, string City, string Region, string Postal, string MinistryofBackground, string PhoneNumber)

        {
            string email = @HttpContext.User.Identity.Name;

            using (Database1Entities3 dc = new Database1Entities3())
            {
                User edit = dc.Users.Find(email);
                edit.FirstName            = FirstName;
                edit.LastName             = LastName;
                edit.Street               = Street;
                edit.City                 = City;
                edit.Region               = Region;
                edit.Postal               = Postal;
                edit.MinistryofBackground = MinistryofBackground;
                edit.PhoneNumber          = PhoneNumber;
                dc.Configuration.ValidateOnSaveEnabled = false;
                dc.SaveChanges();

                return(RedirectToAction("Experience", "Home"));
            }
        }
        public ActionResult Registration([Bind(Exclude = "IsEmailVerified,ActivationCode")] User user)
        {
            bool   Status  = false;
            string message = "";

            if (ModelState.IsValid)
            {
                var isExist = IsEmailExist(user.EmailID);
                if (isExist)
                {
                    ModelState.AddModelError("EmailExist", "Email already exist");
                    return(View(user));
                }
                //ActivationCode
                user.ActivationCode = Guid.NewGuid();
                //Password Hashing
                user.Password        = Crypto.Hash(user.Password);
                user.ConfirmPassword = Crypto.Hash(user.ConfirmPassword);
                user.IsEmailVerified = false;
                using (Database1Entities3 dc = new Database1Entities3())
                {
                    dc.Users.Add(user);
                    dc.SaveChanges();
                    //Send Email to user
                    SendVerificationLinkEmail(user.EmailID, user.ActivationCode.ToString());
                    message = "Registration Successful. Account activation link" +
                              " has been sent to your Email";
                    Status = true;
                }
            }
            else
            {
                message = "Invalid Request";
            }
            ViewBag.Message = message;
            ViewBag.Status  = Status;
            return(View(user));
        }
Esempio n. 22
0
        public ActionResult AddUsers(UserEvent modem)
        {
            Database1Entities3 s       = new Database1Entities3();
            string             message = "";


            if (ModelState.IsValid)
            {
                var IsExist = IsEventExist(modem.EventName);
                if (IsExist)
                {
                    var k = s.UserEvents.Where(a => a.EmailID == modem.EmailID).FirstOrDefault();
                    var v = s.UserEvents.Where(a => a.EventName == modem.EventName).FirstOrDefault();
                    if (k != null && v != null)
                    {
                        ModelState.AddModelError("InValidUser", "User is already registerd into this event");
                        return(View(modem));
                    }
                    s.UserEvents.Add(modem);
                    s.SaveChanges();
                    message         = "Successfully added user for this event and notified for user";
                    ViewBag.Message = message;
                    SendVerificationLinkEmail(modem.EmailID, modem.Roles, modem.EventName);
                    message = "Registration Successful. Account activation link" +
                              " has been sent to your Email";
                    ModelState.Clear();
                    return(View());
                }
                ModelState.AddModelError("InValidEventname", "Event does not exist");
                return(View(modem));
            }
            else
            {
                return(View());
            }
        }
Esempio n. 23
0
        public ActionResult UserRegistration(UserEvent modem)
        {
            Database1Entities3 s       = new Database1Entities3();
            string             message = "";

            if (ModelState.IsValid)
            {
                var isExist = IsEmailidExist(modem.EmailID);
                if (isExist)
                {
                    s.UserEvents.Add(modem);
                    s.SaveChanges();
                    message         = "You are successfully registered for this event..!";
                    ViewBag.Message = message;
                    return(View());
                }
                ModelState.AddModelError("InValidEmail", "Enter your email");
                return(View(modem));
            }
            else
            {
                return(View());
            }
        }
Esempio n. 24
0
 public IHttpActionResult PostAnalyzes([FromBody] Result_analyzes analiz)
 {
     db.Result_analyzes.Add(analiz);
     db.SaveChanges();
     return(Ok(analiz));
 }
Esempio n. 25
0
        public ActionResult Login(login data)
        {
            try
            {
                var users = db.logins.Where(i => i.EMAIL == data.EMAIL && i.PASSWORD == data.PASSWORD).FirstOrDefault();

                if (users == null)
                {
                    TempData["msg"] = "Email id or Password is Wrong";

                    return(RedirectToAction("Login"));
                }
                else if (users.IS_ACTIVE == false)
                {
                    TempData["msg"] = "Your Account is Deactive Please Contact to administrator";
                    return(RedirectToAction("Login"));
                }

                else
                {
                    Session["login"]  = users.ID;
                    Session["login2"] = users.NAME;
                    if (users.ID > 0)
                    {
                        users.LAST_LOGIN = DateTime.Now;
                    }
                    db.SaveChanges();
                    return(RedirectToAction("configuration"));
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }