Exemplo n.º 1
0
        public ActionResult AddResources(FormCollection form)
        {
            Resource resources = new Resource();

            //resources.ResourceId = Convert.ToInt32(form["ResourceId"]);
            resources.ResourceName = form["ResourceName"];
            entities.Resources.Add(resources);
            entities.SaveChanges();
            return(View());
        }
Exemplo n.º 2
0
        public ActionResult Register(FormCollection formCollection)
        {
            try
            {
                int    empId = Convert.ToInt32(formCollection["EmployeeNumber"]);
                string uname = formCollection["NewUsername"];

                //check the record is already available or not
                var checkRegistration = entities.UserRegistrationDetails.Where(q => q.EmployeeNumber == empId).FirstOrDefault();

                var username = entities.UserRegistrationDetails.Where(q => q.Username == uname).FirstOrDefault();



                if (checkRegistration == null && username == null)
                {
                    //inserting data into User registration details table
                    UserRegistrationDetail user = new UserRegistrationDetail();
                    user.EmployeeNumber = empId;
                    user.EmployeeName   = formCollection["EmployeeName"];
                    user.ContactNumber  = formCollection["ContactNumber"];
                    user.Username       = formCollection["NewUsername"];
                    user.Password       = formCollection["Pass"];
                    entities.UserRegistrationDetails.Add(user);

                    //adding data in user questions details
                    UserQuestionDetail userQuestion = new UserQuestionDetail();
                    string             qname        = formCollection["AllQuestions"];
                    int qid = (from res in entities.Questions
                               where res.Question1 == qname
                               select res.QuestionId).FirstOrDefault();

                    userQuestion.QuestionId    = qid;
                    userQuestion.Answer        = formCollection["Answer"];
                    userQuestion.EmpoyeeNumber = Convert.ToInt32(formCollection["EmployeeNumber"]);
                    entities.UserQuestionDetails.Add(userQuestion);
                    entities.SaveChanges();

                    return(Content("<script language='javascript' type='text/javascript'>alert('Employee Registered Successfully');window.location = 'Index';</script>"));
                }
                else
                {
                    //   Content("<script language='javascript' type='text/javascript'>alert('This EmployeeId already Registered');window.location = "Index";</script>");


                    return(Content("<script language='javascript' type='text/javascript'>alert('This Employee already Registered');window.location = 'Index';</script>"));
                }
            }
            catch (Exception)
            {
                return(Content("<script language='javascript' type='text/javascript'>alert('This Username already Registered');window.location = 'Index';</script>"));
            }
        }
Exemplo n.º 3
0
        public ActionResult AddClassroomDetails(FormCollection form)
        {
            ClassRoomDetail detail = new ClassRoomDetail();

            detail.ClassroomId      = Convert.ToInt32(form["AllClassroomId"]);
            detail.ResourceQuantity = Convert.ToInt32(form["ResourceQuantity"]);
            detail.ResourceId       = Convert.ToInt32(form["AllResourceId"]);
            entities.ClassRoomDetails.Add(detail);
            entities.SaveChanges();
            var addedData = entities.ClassRoomDetails.Where(s => s.ClassroomId == detail.ClassroomId);

            //return RedirectToAction("List", "ClassroomDetails");
            return(Content("<script languagr='javascript' type='text/javascript'>alert('Data Added successfully');window.location = '/ClassroomDetails/List';</script>"));
        }
 public ActionResult AddResource(Resource form)
 {
     try
     {
         Resource resource = new Resource();
         resource.ResourceName = form.ResourceName;
         entities.Resources.Add(resource);
         entities.SaveChanges();
         //return View("List");
         // return RedirectToAction("List", "Admin");
         return(Content("<script languagr='javascript' type='text/javascript'>alert('Resource added to the database successfully');window.location = '/Home/Index';</script>"));
     }
     catch (Exception)
     {
         return(Content("<script languagr='javascript' type='text/javascript'>alert('Resource already in the database');window.location = '/Admin/AddResource';</script>"));
     }
 }
        public ActionResult SaveEvent(Event e)
        {
            var status = false;

            using (ClassroomAllocationSystemEntities1 dc = new ClassroomAllocationSystemEntities1())
            {
                if (e.EventID > 0)
                {
                    //Update the event
                    var v = dc.Events.Where(a => a.EventID == e.EventID).FirstOrDefault();
                    if (v != null)
                    {
                        v.Subject     = e.Subject;
                        v.Start       = e.Start;
                        v.End         = e.End;
                        v.Description = e.Description;
                        v.IsfullDay   = e.IsfullDay;

                        v.ClassRoomId = e.ClassRoomId;
                        v.Employeeid  = e.Employeeid;
                        dc.SaveChanges();
                        status = true;
                    }
                }
                else
                {
                    var   count  = dc.ValidateBookingClassroom(e.Start, e.End, e.ClassRoomId).ToList();
                    int?  save   = count.FirstOrDefault();
                    Int32 insert = save.HasValue ? save.Value : 0;
                    if (insert == 0)
                    {
                        dc.Events.Add(e);
                        dc.SaveChanges();

                        status = true;
                    }
                    else
                    {
                        status = false;
                    }
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Exemplo n.º 6
0
        public ActionResult AddClassroom(ClassRoom model, string ClassRoomName, HttpPostedFileBase ClassroomImage)
        {
            try
            {
                if (ClassroomImage != null)
                {
                    model.ClassroomImage = new byte[ClassroomImage.ContentLength];
                    ClassroomImage.InputStream.Read(model.ClassroomImage, 0, ClassroomImage.ContentLength);
                }

                string fileName = Path.GetFileName(ClassroomImage.FileName);
                string filePath = "~/Content/Images/ClassroomImages" + fileName;
                ClassroomImage.SaveAs(Server.MapPath(filePath));

                entities.ClassRooms.Add(model);
                entities.SaveChanges();

                return(RedirectToAction("Welcome", "Resource"));
            }
            catch (Exception)
            {
                throw;
            }
        }
        public JsonResult DeleteEvent(int eventID)
        {
            var status = false;

            using (ClassroomAllocationSystemEntities1 dc = new ClassroomAllocationSystemEntities1())
            {
                var v = dc.Events.Where(a => a.EventID == eventID).FirstOrDefault();
                if (v != null)
                {
                    dc.Events.Remove(v);
                    dc.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }