Esempio n. 1
0
        public JsonResult GetFaculty(long StudentId)
        {
            try
            {
                var FacultyData = (from tableSubject in db.tblSubjects
                                   join tableCourseSubjects in db.tblCourse_Subject on tableSubject.Id equals tableCourseSubjects.SubjectId
                                   join tableBatchAdmission in db.tblBatchAdmissions on tableCourseSubjects.CourseId equals tableBatchAdmission.CourseId
                                   join tableTimeTable in db.tblTimeTableDetails on tableSubject.Id equals tableTimeTable.SubjectId
                                   join timetable in db.tblTimeTables on tableTimeTable.TimeTableId equals timetable.Id
                                   join tableEmployee in db.tblEmployees on tableTimeTable.FacultyId equals tableEmployee.Id
                                   where tableBatchAdmission.StudentId == StudentId && timetable.IsActive == true
                                   select new { tableSubject.Name, FirstName = tableEmployee.FirstName, MiddleName = tableEmployee.MiddleName, LastName = tableEmployee.LastName }).ToList().Select(s => new { s.Name, EmployeeName = s.FirstName + " " + s.MiddleName + " " + s.LastName }).Distinct();

                Facultyobj.FacultyList = new List <Faculties>();
                foreach (var item in FacultyData)
                {
                    var facultytemp = new Faculties();
                    Facultyobj.FacultyList.Add(facultytemp);
                    facultytemp.EmployeeName = item.EmployeeName;
                    facultytemp.SubjectName  = item.Name;
                }

                return(Json(Facultyobj, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(e.ToString(), JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, int universityId, [Bind("Id,Name,Info,UniversityId")] Faculties faculties)
        {
            if (id != faculties.Id)
            {
                return(NotFound());
            }
            ViewBag.UniversityId = universityId;

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(faculties);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FacultiesExists(faculties.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Faculties", new { id = universityId }));
            }
            ViewData["UniversityId"] = new SelectList(_context.Universities, "Id", "Name", faculties.UniversityId);
            //return View(faculties);
            return(RedirectToAction("Index", "Faculties", new { id = universityId }));
        }
        public IHttpActionResult PutFaculties(int id, Faculties faculties)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != faculties.Id)
            {
                return(BadRequest());
            }

            db.Entry(faculties).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FacultiesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 4
0
        public Student(
            string firstName,
            string middleName,
            string lastName,
            string sSN,
            string address,
            string phoneNbr,
            string email,
            string course,
            Faculties faculty,
            Specialties specialty,
            Universities university

            )
        {
            this.FirstName        = firstName;
            this.MiddleName       = middleName;
            this.LastName         = lastName;
            this.FacultyNumber    = sSN;
            this.PhoneNumber      = phoneNbr;
            this.Email            = email;
            this.PermanentAddress = address;
            this.Course           = course;
            this.Faculty          = faculty;
            this.Specialty        = specialty;
            this.University       = university;
        }
Esempio n. 5
0
        private BaseApplication MapToApplication(InputModel inputModel)
        {
            var fac = Faculties.FirstOrDefault(x => x.FacultyId == inputModel.FacultyId);
            var lec = Lecterns.FirstOrDefault(x => x.LecternId == inputModel.LecternId);

            var application = new BaseApplication
            {
                Email      = inputModel.Email,
                Password   = inputModel.Password,
                UserType   = inputModel.UserType,
                DocNo      = inputModel.DocNo,
                FirstName  = inputModel.FirstName,
                SecondName = inputModel.SecondName,
                Faculty    = Faculties.FirstOrDefault(x => x.FacultyId == inputModel.FacultyId),
                Lectern    = Lecterns.FirstOrDefault(x => x.LecternId == inputModel.LecternId),
                CreatedAt  = DateTime.Now
            };

            if (inputModel.UserType == UserType.Student)
            {
                application.UserType   = UserType.Student;
                application.DegreeType = inputModel.DegreeType;
                application.Curriculum = Curriculums.FirstOrDefault(x => x.CurriculumId == inputModel.CurriculumId);
                application.YearNo     = inputModel.YearNo;
            }
            else
            {
                application.UserType   = UserType.Lecturer;
                application.DegreeType = DegreeType.Unknown;
                application.Curriculum = null;
            }

            return(application);
        }
        public IActionResult Add(Faculties admin, string branch, double budgetAllocation, string FundGoes, string Project, string Vote, string IsInProcumentPlan, string Purpose, string TelephonNumber)
        {
            //int max_id = 0;
            //try
            //{
            //    max_id = _db.PurchaseRequests.Max((pr) => pr.Id);
            //}
            //catch
            //{

            //}

            //PurchaseRequest pr = new PurchaseRequest()
            //{

            //    Id = max_id,
            //    Faculty = admin,
            //    Branch = branch,
            //    BudgetAllocation = budgetAllocation,
            //    FundGoes = FundGoes,
            //    Project = Project,
            //    Vote = Vote,
            //    IsInProcumentPlan = IsInProcumentPlan,
            //    Purpose = Purpose,
            //    TelephonNumber = TelephonNumber
            //};
            //_db.PurchaseRequests.Add(pr);
            //_db.SaveChanges();
            return(Ok());
        }
Esempio n. 7
0
        private async void OnRemoveFaculty()
        {
            var facultySpecialities = await _sRepo.GetFilteredSpecialtiesAsync(s =>
                                                                               s.FacultyId == SelectedFaculty.FacultyId);

            if (facultySpecialities.Count > 0)
            {
                var result = MessageBox.Show(
                    "Вы точно хотите удалить факультет вместе с прикреплёнными специальностями и студентами?",
                    "К этому факультету прикреплены специальности.",
                    MessageBoxButton.YesNo);

                switch (result)
                {
                case MessageBoxResult.Yes:
                    break;

                case MessageBoxResult.No:
                    return;

                default:
                    return;
                }
            }

            await _repo.DeleteFacultyWithSpecialitiesAndStudentsAsync(SelectedFaculty.FacultyId);

            var faculty = Faculties.FirstOrDefault(f => f.FacultyId == SelectedFaculty.FacultyId);

            if (faculty != null)
            {
                Faculties.Remove(faculty);
            }
        }
        private void RemoveRow_ButtonClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (CurrentRow != null)
                {
                    var messageBoxResult = MessageBox.Show("Вы действительно удалить данный факультет?", "Подтверждение действия",
                                                           MessageBoxButton.YesNo, MessageBoxImage.Question);

                    if (messageBoxResult == MessageBoxResult.Yes)
                    {
                        Connection.Database.faculties.Remove(CurrentRow);
                        Faculties.Remove(CurrentRow);

                        Connection.Database.SaveChanges();
                    }
                }
                else
                {
                    MessageBox.Show("Аудитория не выбрана.", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Ошибка сохранения", MessageBoxButton.OK, MessageBoxImage.Warning);
                Connection.Database.faculties.Remove(CurrentRow);
            }
        }
Esempio n. 9
0
 public void RemoveFaculty(Faculty facultyToRemove)
 {
     if (Faculties.Contains(facultyToRemove))
     {
         Faculties.Remove(facultyToRemove);
     }
 }
Esempio n. 10
0
        public async Task <IActionResult> PutFaculties(string id, Faculties faculties)
        {
            if (id != faculties.FacultyId)
            {
                return(BadRequest());
            }

            _context.Entry(faculties).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FacultiesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 11
0
 public Student(
     string firstName,
     string middleName,
     string lastName,
     int ssnNumber,
     string permAdress,
     string phoneNumber,
     string email,
     string course,
     Specialties specialty,
     Universities university,
     Faculties faculty)
 {
     this.FirstName       = firstName;
     this.MiddleName      = middleName;
     this.LastName        = lastName;
     this.SSN             = ssnNumber;
     this.PermanentAdress = permAdress;
     this.PhoneNumber     = phoneNumber;
     this.Email           = email;
     this.Course          = course;
     this.Specialty       = specialty;
     this.University      = university;
     this.Faculty         = faculty;
 }
Esempio n. 12
0
        private async void OnUpdateFaculty()
        {
            var result = await _repo.UpdateFacultyAsync(SelectedFaculty);

            var faculty = Faculties.FirstOrDefault(f => f.FacultyId == SelectedFaculty.FacultyId);

            faculty.CopyProperties(SelectedFaculty);
        }
Esempio n. 13
0
        public void createFaculty(string n, int Uid)
        {
            Faculties f = new Faculties();

            f.NameOfFaculties = n;
            f.UniversId       = Uid;
            unitOfWork.Faculties.Create(f);
        }
 public FacilityBookingRequestDetails(int reqid, int eventID, Faculties fac, string facilityID, int p)
 {
     this.requestid = reqid;
     this.priority = p;
     this.fac = fac;
     this.facilityID = facilityID;
     this.eventID = eventID;
 }
Esempio n. 15
0
        private void Add()
        {
            var d = new Faculty();

            Faculties.Add(d);
            SelectedFaculty = d;
            RaisePropertyChanged("Faculties");
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Faculties faculties = db.Faculties.Find(id);

            db.Faculties.Remove(faculties);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 17
0
 public async Task Initialize(IDatabaseFiller dbFiller)
 {
     if (!Universities.Any() && !Faculties.Any() && !Programmes.Any())
     {
         DataFixture.Initialize(this);
         await dbFiller.Fill(this);
     }
 }
Esempio n. 18
0
 public Student(string firstName, string lastName, int ssn, Specialties spec, Faculties fac)
 {
     this.FirstName = firstName;
     this.LastName  = lastName;
     this.SSN       = ssn;
     this.Specialty = spec;
     this.Faculty   = fac;
     counter++;
 }
Esempio n. 19
0
 public async Task <IActionResult> AddNewFaculty(Faculties faculty)
 {
     if (!String.IsNullOrEmpty(faculty.Name) && !String.IsNullOrEmpty(faculty.Description) && !String.IsNullOrEmpty(faculty.Address) && faculty.MapLocationX != 0.0 && faculty.MapLocationY != 0.0)
     {
         subjectManagement.AddNewFaculty(faculty.Name, faculty.Description, faculty.Address, faculty.MapLocationX, faculty.MapLocationY);
         return(RedirectToAction("Profile", "Account"));
     }
     return(View());
 }
Esempio n. 20
0
        public void Delete(int id)
        {
            Faculties faculty = db.Faculties.Find(id);

            if (faculty != null)
            {
                db.Faculties.Remove(faculty);
            }
        }
Esempio n. 21
0
        public JsonResult Post([FromBody] string NameOfUniver, [FromBody] string NameOfFaculty)
        {
            Univers choisenUniver = uS.getUniverByName(NameOfUniver);

            List <Faculties> facultiesOfUniver = new List <Faculties>(fS.getFacultiesOfUniver(choisenUniver.Id));

            Faculties choisenFaculty = facultiesOfUniver.First(c => c.NameOfFaculties == NameOfFaculty);

            return(Json(sS.getSubjectsOfFaculty(choisenFaculty.Id)));
        }
Esempio n. 22
0
        public string Change(Faculties changedFaculty, Faculties newFaculty)
        {
            if (IsExist(changedFaculty))
            {
                context.UpdateFaculty(changedFaculty.ShortName, newFaculty.FullName);

                return("Изменение произошло успешно!");
            }
            return("Изменяемого объекта не существует!");
        }
        private async void OnUpdateSpecialty()
        {
            SelectedSpeciality.Faculty = Faculties.FirstOrDefault(f => f.FacultyId == SelectedSpeciality.FacultyId);

            var result = await _repo.UpdateSpecialtyAsync(SelectedSpeciality);

            var specialty = Specialities.FirstOrDefault(s => s.SpecialtyId == SelectedSpeciality.SpecialtyId);

            specialty.CopyProperties(SelectedSpeciality);
        }
Esempio n. 24
0
        public static Faculties GetFacultyObject(string ShortName, string FullName)
        {
            Faculties faculty = new Faculties()
            {
                ShortName = ShortName,
                FullName  = FullName
            };

            return(faculty);
        }
 public ActionResult Edit([Bind(Include = "id,UserName,Password,Activation,FirstName,LastName,Gender,Picture,Comment,TimeExtension,Designation,created_at,edited_at")] Faculties faculties)
 {
     if (ModelState.IsValid)
     {
         db.Entry(faculties).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(faculties));
 }
        public IHttpActionResult GetFaculties(int id)
        {
            Faculties faculties = db.Faculties.Find(id);

            if (faculties == null)
            {
                return(NotFound());
            }

            return(Ok(faculties));
        }
 public ActionResult Edit([Bind(Include = "FacultyId,FacultyName,Email,Address,PhoneNumber,IsDelete,IsActive,LastUpdate")] Faculties faculties)
 {
     faculties.LastUpdate = DateTime.Now;
     if (ModelState.IsValid)
     {
         db.Entry(faculties).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(faculties));
 }
Esempio n. 28
0
 public Student(string firstName, string middleName, string lastName, uint ssn, string address, string phoneNumber,
                string email, byte course, Specialties specialtyName, Faculties facultyName, Universities universityName)
     : this(firstName, middleName, lastName, ssn)
 {
     this.PermanentAddress = address;
     this.MobilePhone      = phoneNumber;
     this.EMail            = email;
     this.Course           = course;
     this.Specialty        = specialtyName;
     this.Faculty          = facultyName;
     this.University       = universityName;
 }
Esempio n. 29
0
        public static List<Facility> SearchFacilities(Faculties fac, int minCap, int maxCap, RoomType rtype, bool hasWebcast, bool hasFlexiSeat,
            bool hasVidConf, bool hasMIC, bool hasProjector, bool hasVisualizer)
        {
            List<Facility> fList = SearchFacilities(minCap, maxCap, rtype, hasWebcast, hasFlexiSeat,
            hasVidConf, hasMIC, hasProjector, hasVisualizer);

            List<Facility> filteredByFacList = (from faci in fList
                                                where faci.Faculty == fac
                                                select faci).ToList<Facility>();

            return filteredByFacList;
        }
Esempio n. 30
0
 public string Remove(Faculties faculties)
 {
     if (IsExist(faculties))
     {
         if (IsRemoved(faculties))
         {
             return("Удаление произошло успешно!");
         }
         return("Данный объект не был удален!");
     }
     return("Данный объект не существует!");
 }
        public IHttpActionResult PostFaculties(Faculties faculties)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Faculties.Add(faculties);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = faculties.Id }, faculties));
        }
Esempio n. 32
0
 public FacilityBookingRequest(int eventid,
     string requestorid, DateTime reqStart, DateTime reqEnd, Faculties fac)
 {
     this.eventID = eventid;
     this.requestStartDateTime = reqStart;
     this.requestEndDateTime = reqEnd;
     this.requestorID = requestorid;
     this.fac = fac;
     this.status = BookingStatus.Pending;
     BookingTime = DateTime.Now;
     remarks = "";
 }
Esempio n. 33
0
        public void Seed()
        {
            if (!Faculties.Any())
            {
                Faculties.Add(new Faculty {
                    Name = "FNWI"
                });
                SaveChanges();
            }

            if (!SecurityQuestions.Any())
            {
                List <SecurityQuestions> questions = new List <SecurityQuestions>();
                void AddQuestion(string text, DeviceType mask)
                {
                    questions.Add(new Data.SecurityQuestions()
                    {
                        Text = text,
                        Mask = mask,
                    });
                }

                AddQuestion("Does the device have encrypted storage?", DeviceType.All);
                AddQuestion("Are local accounts only accessible with strong passwords?", DeviceType.All);
                AddQuestion("Does the device have a strong access code(minimum 6 characters) other than the SIM card PIN code?", DeviceType.Mobile | DeviceType.Tablet);
                AddQuestion("The OS and all applications are maintained by a supplier or community, and are up to date including security updates.", DeviceType.All);
                AddQuestion("Applicable anti malware and antivirus solutions are present, active and up to date.", DeviceType.All);
                AddQuestion("Local (application) firewall is active and alerts the user to unusual behaviour.", DeviceType.Desktop | DeviceType.Laptop);
                AddQuestion("Laptop or desktop should be automatically locked after a pre-set period of inactivity after a maximum of 15 minutes and phones or tablets after 5 minutes.", DeviceType.Desktop | DeviceType.Laptop);
                AddQuestion("Remote wipe, lock, or effective data protection measures to prevent loss of setting information in the event of theft should be in place.", DeviceType.All);
                SecurityQuestions.AddRange(questions);
                SaveChanges();
            }

            int facultyId = Faculties.First(f => f.Name == "FNWI").Id;
            var userIds   = new string[] { User.ImporterId, User.IntuneServiceId, User.LabnetId, User.ExpireId };

            foreach (string id in userIds)
            {
                if (!Users.Any(u => u.UserName == id))
                {
                    Users.Add(new User()
                    {
                        Name      = id,
                        UserName  = id,
                        FacultyId = facultyId,
                        Email     = "*****@*****.**",
                    });
                    SaveChanges();
                }
            }
        }
Esempio n. 34
0
 public static void AddFacilityAdmin(User assigner, string userid, Faculties fac)
 {
     if (assigner.isSystemAdmin)
     {
         SystemAdmin admin = new SystemAdmin(assigner);
         admin.AddFacilityAdmin(userid, fac);
     }
     else
     {
         throw new FaultException<SException>(new SException(),
             new FaultReason("You do not have the permission to perform this task!"));
     }
 }
Esempio n. 35
0
 //constuctors
 public Student(string firstName, string middleName, string lastName, long ssn, string permanentAddress,  string mobilePhoneEmail, int course, Specialties specialty, Universities university, Faculties faculty)
 {
     this.firstName = firstName;
     this.middleName = middleName;
     this.lastName = lastName;
     this.ssn = ssn;
     this.permanentAddress = permanentAddress;
     this.mobilePhoneEmail = mobilePhoneEmail;
     this.course =  course;
     this.specialty = specialty;
     this.university = university;
     this.faculty = faculty;
 }
 public StudentInfoWindow(string fullname, string group, Faculties faculty, string telephone, string email,
     string address, double averageMark)
 {
     InitializeComponent();
     PIB.Text = fullname;
     GroupText.Text = group;
     FacultyText.Text = faculty.ToString();
     TelephoneText.Text = telephone;
     EmailText.Text = email;
     Email.NavigateUri = new Uri(string.Concat("mailto:", email,
         "?subject=Лист згенеровано програмно"));
     AdressText.Text = address;
     AverageMarkText.Text = Math.Round(averageMark, 2).ToString();
 }
Esempio n. 37
0
 public Student(string firstName, string middleName, string lastName,
     string socialSecurityNumber, string address, string mobilePhone, string email, string course,
     Universities university, Faculties faculty, Specialties speciality)
 {
     this.FirstName = firstName;
     this.MiddleName = middleName;
     this.LastName = lastName;
     this.SocialSecurityNumber = socialSecurityNumber;
     this.Address = address;
     this.MobilePhone = mobilePhone;
     this.Email = email;
     this.Course = course;
     this.University = university;
     this.Faculty = faculty;
     this.Speciality = speciality;
 }
Esempio n. 38
0
        public static List<Facility> GetVenues(Faculties fac)
        {
            DAL dalDataContext = new DAL();
            try
            {
                List<Facility> fList = (from faci in dalDataContext.Facilities
                                        where  faci.Faculty == fac
                                        select faci).ToList<Facility>();

                return fList;
            }
            catch (Exception ex)
            {
                throw new FaultException<SException>(new SException(ex.Message),
                   new FaultReason("An Error occured retrieving facilities, Please Try Again!"));
            }
        }
Esempio n. 39
0
        public static bool AddFacilityAdmin(SystemAdmin assigner, string useridToAssign, Faculties f)
        {
            if (assigner.UserID == useridToAssign)
            {
                throw new FaultException<SException>(new SException(),
                    new FaultReason("You cannot Remove your own role!"));
            }
            else
            {
                RemoveAllRoles(useridToAssign); //Remove existing role
                DAL dalDataContext = new DAL();
                try
                {
                    FacilityAdmin fa = (from facAdm in dalDataContext.facAdmins
                                        where facAdm.Faculty == f
                                        select facAdm).FirstOrDefault<FacilityAdmin>();

                    if (fa == null)
                    {
                        Table<FacilityAdmin> sTable = dalDataContext.facAdmins;
                        fa = new FacilityAdmin(useridToAssign, f);
                        sTable.InsertOnSubmit(fa);
                        sTable.Context.SubmitChanges();
                    }
                    else
                    {
                        fa.UserID = useridToAssign;
                        dalDataContext.SubmitChanges();
                    }

                    string msg = assigner.Name + " has assigned you to the role of Facility Admin for " +
                         f.ToString().Replace("_", " ");

                    string title = "You have been Added to the System Group - Facility Administrator";

                    NotificationController.sendNotification(assigner.UserID, useridToAssign, title, msg);

                    return true;
                }
                catch (Exception)
                {
                    throw new FaultException<SException>(new SException(),
                       new FaultReason("An Error occured while the system is Adding the user's role, Please Try Again!"));
                }
            }
        }
Esempio n. 40
0
 public Facility(string id, Faculties fac, string loc, string bookingCon, string techCon, int cap,
     RoomType rType, bool hasWebCast, bool flexiSeat, bool vidConf, bool mic, bool projector, bool visualizer)
 {
     this.bookingContact = bookingCon;
     this.facilityID = id;
     this.fac = fac;
     this.location = loc;
     this.techContact = techCon;
     this.bookingContact = bookingCon;
     this.capacity = cap;
     this.rType = rType;
     this.webcast = hasWebCast;
     this.flexibleSeating = flexiSeat;
     this.videoConferencing = vidConf;
     this.mic = mic;
     this.projector = projector;
     this.visualizer = visualizer;
 }
        public static List<FacilityBookingConfirmed> GetActivitesForLocation(User approver, DateTime day, Faculties faculty, string venue)
        {
            if ((!approver.isFacilityAdmin) && (!approver.isSystemAdmin))
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To View such requests!"));
            }

            DAL dalDataContext = new DAL();

            List<FacilityBookingConfirmed> cList =
                (from confirmed in dalDataContext.facConfirmedBookings
                 where confirmed.Faculty == faculty &&
                 confirmed.Venue == venue &&
                 confirmed.RequestStartDateTime >= day &&
                 confirmed.RequestEndDateTime <= day.AddDays(1)
                 select confirmed).ToList<FacilityBookingConfirmed>();

            return cList;
        }
Esempio n. 42
0
        public static string GetFacilityAdmin(Faculties f)
        {
            DAL dalDataContext = new DAL();
            FacilityAdmin fa = (from facAdm in dalDataContext.facAdmins
                                where facAdm.Faculty == f
                                select facAdm).FirstOrDefault<FacilityAdmin>();

            if (fa == null || fa.UserID.Trim().Length == 0)
            {
                //if faculty does not have an admin, sys admin take over
                User user = (from users in dalDataContext.users
                          from sysRole in dalDataContext.sRole
                          where users.UserID == sysRole.UserID &&
                          sysRole.RoleLevel == (int)EnumRoles.System_Admin
                          select users).FirstOrDefault<User>();
                return user.UserID;
            }
            else
            {
                //Return the faculty admin
                return fa.UserID;
            }
        }
Esempio n. 43
0
        public static void RemoveFacility(User user, string locID, Faculties fac)
        {
            if (!user.isFacilityAdmin)
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Remove Facility!"));
            }
            DAL dalDataContext = new DAL();
            try
            {
                Facility f = (from faci in dalDataContext.Facilities
                              where faci.FacilityID == locID && faci.Faculty == fac
                              select faci).FirstOrDefault();

                if (f != null)
                {
                    if ((user.isSystemAdmin) || (f.Faculty == user.UserFaculty))
                    {
                        dalDataContext.Facilities.DeleteOnSubmit(f);
                        dalDataContext.SubmitChanges();
                    }
                    else if (f.Faculty != user.UserFaculty)
                    {
                        if (!user.isSystemAdmin)
                            throw new FaultException<SException>(new SException(),
                       new FaultReason("You do not belong to the faculty of the facility!"));
                    }

                }

            }
            catch (Exception ex)
            {
                throw new FaultException<SException>(new SException(ex.Message),
                   new FaultReason("An Error occured while deleting the facility, Please Try Again!"));
            }
        }
Esempio n. 44
0
 public List<Facility> SearchFacilities(Faculties fac, int minCap, int maxCap, RoomType rtype, bool hasWebcast, bool hasFlexiSeat,
     bool hasVidConf, bool hasMIC, bool hasProjector, bool hasVisualizer)
 {
     return FacilityController.SearchFacilities(fac, minCap, maxCap, rtype, hasWebcast, hasFlexiSeat, hasVidConf, hasMIC, hasProjector, hasVisualizer);
 }
 //Facility Booking Confirmed
 public static List<FacilityBookingConfirmed> GetActivitesForLocation(User approver, DateTime day, Faculties faculty, string venue)
 {
     return FaciConfirmedBookingController.GetActivitesForLocation(approver, day, faculty, venue);
 }
 //Create the list on the client
 public static bool AddBookingRequest(User user, EventDay evntDay, DateTime reqStart,
     DateTime reqEnd, Faculties fac, List<FacilityBookingRequestDetails> reqDetails)
 {
     return FaciRequestController.AddBookingRequest(user, evntDay, reqStart, reqEnd, fac, reqDetails);
 }
Esempio n. 47
0
 public bool AddFacilityAdmin(string useridToAssign, Faculties f)
 {
     return SysAdminController.AddFacilityAdmin(this, useridToAssign, f);
 }
Esempio n. 48
0
 public FacilityAdmin(string userid, Faculties fac)
 {
     this.userid = userid;
     this.fac = fac;
 }
Esempio n. 49
0
 public static void UpdateFacility(User user, string venue, Faculties faculty, string loc,
     string bookingCon, string techCon, int cap, RoomType rtype, bool hasWebcast, bool hasFlexiSeat,
     bool hasVidConf, bool hasMIC, bool hasProjector, bool hasVisualizer)
 {
     if (!user.isFacilityAdmin)
     {
         throw new FaultException<SException>(new SException(),
            new FaultReason("Invalid User, User Does Not Have Rights To Remove Facility!"));
     }
     DAL dalDataContext = new DAL();
     Facility f = (from faci in dalDataContext.Facilities
                   where faci.FacilityID == venue && faci.Faculty == faculty
                   select faci).FirstOrDefault();
     if (f == null)
     {
         Table<Facility> facs = dalDataContext.Facilities;
         Facility fac = new Facility(venue, faculty, loc, bookingCon, techCon, cap, rtype,
             hasWebcast, hasFlexiSeat, hasVidConf, hasMIC, hasProjector, hasVisualizer);
         facs.InsertOnSubmit(fac);
         facs.Context.SubmitChanges();
     }
     else
     {
         f.Capacity = cap;
         f.BookingContact = bookingCon;
         f.Location = loc;
         f.TechContact = techCon;
         //V0.3 Additional Fields
         f.HasflexibleSeating = hasFlexiSeat;
         f.HasMicrophone = hasMIC;
         f.HasProjector = hasProjector;
         f.HasVideoConferencing = hasVidConf;
         f.HasVisualizer = hasVisualizer;
         f.HasWebCast = hasWebcast;
         f.RoomType = rtype;
         dalDataContext.SubmitChanges();
     }
 }
Esempio n. 50
0
        public static string GetFacultyAdmin(Faculties fac)
        {
            DAL dalDataContext = new DAL();
            FacilityAdmin fa = (from facAdm in dalDataContext.facAdmins
                                where facAdm.Faculty == fac
                                select facAdm).FirstOrDefault<FacilityAdmin>();

            if (fa == null || fa.UserID.Trim().Length == 0)
            {
                throw new FaultException<SException>(new SException(),
                    new FaultReason("There is no facility admin for the defined faculty!"));
            }
            else
            {
                //Return the faculty admin
                return fa.UserID;
            }
        }
Esempio n. 51
0
        /// <summary>
        ///     Додає нову групу у список груп
        /// </summary>
        /// <param name="name">Назва групи</param>
        /// <param name="faculty">Факультет</param>
        public static void AddGroup(string name, Faculties faculty)
        {
            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                connection.Open();
                SqlCommand count = new SqlCommand("SELECT COUNT(*) FROM [Group] WHERE Name = @Name", connection);
                count.Parameters.Add("@Name", SqlDbType.VarChar).Value = name;
                if ((int)count.ExecuteScalar() > 0)
                    return;
                using (SqlTransaction transaction = connection.BeginTransaction())
                using (SqlCommand query = new SqlCommand("INSERT INTO [Group](Name, Faculty) VALUES(@Name, @Faculty)", connection, transaction))
                {
                    try
                    {
                        query.Parameters.Add("@Name", SqlDbType.VarChar, 10).Value = name;
                        query.Parameters.Add("@Faculty", SqlDbType.Int).Value = (int) faculty;
                        query.ExecuteNonQuery();
                        transaction.Commit();
                    }
                    catch
                    {
                        transaction.Rollback();
                        throw;
                    }
                }
            }

        }
 //Constructor
 public University(Universities uni, Faculties facultet, Specialties specialty)
 {
     this.Univercities = uni;
     this.Faculty = facultet;
     this.Specialty = specialty;
 }
Esempio n. 53
0
 public void UpdateFacility(User user, string venue, Faculties faculty, string loc,
     string bookingCon, string techCon, int cap, RoomType rtype, bool hasWebcast, bool hasFlexiSeat,
     bool hasVidConf, bool hasMIC, bool hasProjector, bool hasVisualizer)
 {
     FacilityController.UpdateFacility(user, venue, faculty, loc, bookingCon, techCon, cap, rtype,
         hasWebcast, hasFlexiSeat, hasVidConf, hasMIC, hasProjector, hasVisualizer);
 }
Esempio n. 54
0
        public static List<Student> GetStudentsByFaculty(Faculties faculty)
        {
            List<Student> students = new List<Student>();
            using (SqlConnection connection = new SqlConnection(ConnectionString))
            using (SqlCommand command = new SqlCommand("SELECT Name FROM [Group] WHERE Faculty = @Faculty", connection))
            {
                connection.Open();
                command.Parameters.Add("@Faculty", SqlDbType.Int).Value = (int) faculty;
                var reader = command.ExecuteReader();
                if(reader.HasRows)
                    while (reader.Read())
                    {
                        students.AddRange(GetStudentsByGroup(reader["Name"] as string));
                    }

                return students;
            }
        }
Esempio n. 55
0
 public static Dictionary<string, int> GetGroupsByFaculty(Faculties faculty)
 {
     Dictionary<string, int> groups = new Dictionary<string, int>();
     using (SqlConnection connection = new SqlConnection(ConnectionString))
     using (SqlCommand command = new SqlCommand("SELECT GroupId, Name FROM [Group] WHERE Faculty = @Faculty", connection))
     {
         connection.Open();
         command.Parameters.Add("@Faculty", SqlDbType.Int).Value = (int)faculty;
         using (var reader = command.ExecuteReader())
         {
             if (reader.HasRows)
                 while (reader.Read())
                     groups.Add((string) reader["Name"], (int) reader["GroupId"]);
         }
     }
     return groups;
 }
Esempio n. 56
0
        public static bool AddBookingRequest(User sender, EventDay evntDay, DateTime reqStart,
            DateTime reqEnd, Faculties fac, List<FacilityBookingRequestDetails> reqDetails)
        {
            if (sender.isFacilityAdmin ||
                sender.isAuthorized(EventController.GetEvent(evntDay.EventID),
                EnumFunctions.Manage_Facility_Bookings))//, EnumFunctions.ManageFacBookings))
            {
                bool success;
                try
                {
                    //request start > evnt.StartDateTime do not check, can book earlier...
                    if (reqStart.AddHours(2) < evntDay.StartDateTime)
                    {
                        throw new FaultException<SException>(new SException(),
                      new FaultReason("You cannot book a facility more than 2hours before your event start time"));
                    }

                    if (reqEnd.AddHours(-2) > evntDay.EndDateTime)
                    {
                        throw new FaultException<SException>(new SException(),
                      new FaultReason("You cannot book a facility for more than 2 hours after your event end time"));
                    }

                    if (reqEnd.Date != reqStart.Date)
                    {
                        if (reqEnd.Date == reqStart.Date.AddDays(1) && reqEnd.Hour == 0 && reqEnd.Minute == 0 && reqEnd.Second == 0)
                        {
                            reqEnd = reqEnd.AddSeconds(-1);
                        }
                        else
                        {
                            throw new FaultException<SException>(new SException(),
                                new FaultReason("You cannot book a across multiple days"));
                        }
                    }

                    DAL dalDataContext = new DAL();
                    Table<FacilityBookingRequest> facReq = dalDataContext.facBookReqs;
                    using (TransactionScope tScope = new TransactionScope(TransactionScopeOption.Required))
                    {
                        FacilityBookingRequest f = new FacilityBookingRequest(evntDay.EventID,
                            sender.UserID, reqStart, reqEnd, fac);
                        facReq.InsertOnSubmit(f);
                        facReq.Context.SubmitChanges();

                        f = (from req in dalDataContext.facBookReqs
                             where req.EventID == evntDay.EventID &&
                             req.RequestorID == sender.UserID
                             orderby req.BookingTime descending
                             select req).FirstOrDefault<FacilityBookingRequest>();

                        success = FaciReqDetailsController.AddFacilityBookingReqDetails(f.RequestID, reqDetails);
                        tScope.Complete();
                    }
                }
                catch (Exception ex)
                {
                    throw new FaultException<SException>(new SException(),
                      new FaultReason("An Error occured While Adding Booking Request: " + ex.Message));
                }
                if (success)
                {

                    string msg = sender.Name + " has sent you a facility booking request for "
                                    + EventController.GetEvent(evntDay.EventID).Name +
                                     Environment.NewLine + Environment.NewLine +
                                    " Please check the Facility Requests for more details.";

                    string title = "New Facility Booking Request";
                    string facAdmin = SysRoleController.GetFacilityAdmin(fac);

                    NotificationController.sendNotification(sender.UserID, facAdmin, title, msg);
                }
                return success;
            }
            else
            {
                throw new FaultException<SException>(new SException(),
                    new FaultReason("User is not authorized to add a facility booking request!"));
            }
        }
Esempio n. 57
0
 public string GetFacilityAdminFaculty(Faculties fac)
 {
     return SysRoleController.GetFacultyAdmin(fac);
 }
Esempio n. 58
0
 public void RemoveFacility(User user, string venue, Faculties fac)
 {
     FacilityController.RemoveFacility(user, venue, fac);
 }
Esempio n. 59
0
 public void AssignLocationAdmin(User assigner, string userid, Faculties fac)
 {
     SysRoleController.AddFacilityAdmin(assigner, userid, fac);
 }
Esempio n. 60
0
 //public List<Facility> GetVenues(int minCap = 0, int maxCap = int.MaxValue)
 //{
 //    return FacilityController.GetVenues(minCap, maxCap);
 //}
 public List<Facility> GetVenuesByFaculty(Faculties fac)
 {
     return FacilityController.GetVenues(fac);
 }