Пример #1
0
        public ActionResult DeleteAccount(string id)
        {
            try
            {
                var toDeleteProfile = new UserProfile {
                    UserID = id
                };
                var toDeleteUser = new AspNetUser {
                    Id = id
                };

                db.Configuration.AutoDetectChangesEnabled = false;
                db.UserProfiles.Remove(toDeleteProfile);
                db.AspNetUsers.Remove(toDeleteUser);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.InnerException.Message);
            }
            finally
            {
                db.Configuration.AutoDetectChangesEnabled = true;
            }

            return(RedirectToAction("Accounts"));
        }
Пример #2
0
        public ActionResult Index(WebSetting model)
        {
            var dbSetting  = db.WebSettings.FirstOrDefault();
            var tempPeriod = db.ValidationPeriods.Where(e => e.PeriodID.Equals(model.PeriodID)).FirstOrDefault();
            var period     = db.ValidationPeriods.Where(e => e.AcademicYearStart.Equals(tempPeriod.AcademicYearStart) && e.AcademicYearEnd.Equals(tempPeriod.AcademicYearEnd) && e.Term.Equals(model.ValidationPeriod.Term)).FirstOrDefault();

            if (period == null)
            {
                TempData["MessageType"] = "warning";
                TempData["Message"]     = "Validation Period is not found";
                return(RedirectToAction("Index"));
            }
            dbSetting.ValidationPeriod = period;
            dbSetting.ValidationOpen   = model.ValidationOpen;

            db.SaveChanges();

            ViewBag.MessageType = "success";
            ViewBag.Message     = "Successfully changed website settings";
            ViewBag.Periods     = db.ValidationPeriods.ToList();
            return(View(db.WebSettings.FirstOrDefault()));
        }
Пример #3
0
        public static bool AddMessage(lipatdbEntities db, string message, string id)
        {
            if (message.Equals(""))
            {
                return(false);
            }

            AspNetUser    user = db.AspNetUsers.Where(e => e.Id.Equals(id)).FirstOrDefault();
            AdminAuditLog log  = new AdminAuditLog()
            {
                DateTime = DateTime.Now,
                Event    = message,
                UserID   = user.Id,
            };

            db.AdminAuditLogs.Add(log);
            db.SaveChanges();
            return(true);
        }
Пример #4
0
        public ActionResult Submit(ValidationRequest request)
        {
            string id = User.Identity.GetUserId();

            //db.ValidationRequests.Where(e => e.RequestID.Equals(request.RequestID)).FirstOrDefault().AdminID = id;
            //db.ValidationRequests.Where(e => e.RequestID.Equals(request.RequestID)).FirstOrDefault().AspNetUser1 = db.AspNetUsers.Where(e => e.Id.Equals(id)).FirstOrDefault();
            //db.ValidationRequests.Where(e => e.RequestID.Equals(request.RequestID)).FirstOrDefault().DateEvaluated = DateTime.Now;
            //db.ValidationRequests.Where(e => e.RequestID.Equals(request.RequestID)).FirstOrDefault().StatusID = request.StatusID;
            //db.ValidationRequests.Where(e => e.RequestID.Equals(request.RequestID)).FirstOrDefault().Remarks = request.Remarks;

            request.AdminID         = id;
            request.AspNetUser1     = db.AspNetUsers.Where(e => e.Id.Equals(id)).FirstOrDefault();
            request.DateEvaluated   = DateTime.Now;
            request.ValidationStatu = db.ValidationStatus.Where(e => e.StatusID == request.RequestID).FirstOrDefault();

            db.Entry(request).State = System.Data.Entity.EntityState.Modified;

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public void UploadStudentRequest(ValidationRequest requestModel)
 {
     dbObject.ValidationRequests.Add(requestModel);
     dbObject.SaveChanges();
 }
        // A N N O U N C E M E N T S \\

        public void UploadAnnouncement(Announcement announcementModel)
        {
            dbObject.Announcements.Add(announcementModel);
            dbObject.SaveChanges();
        }