Example #1
0
        public ActionResult AddNewProject(new_project newProject)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (pimsEntitiesNew db = new pimsEntitiesNew())
                    {
                        db.new_project.Add(newProject);
                        db.SaveChanges();
                    }
                    ModelState.Clear();
                    using (pimsEntitiesNew dbpid = new pimsEntitiesNew())
                    {
                        var crum = dbpid.new_project.Max(d => d.project_id);
                        ViewBag.Result = "Your Project:" + crum.ToString() + " successfully added to the records";
                    }
                }
            }

            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
            }
            return(View());
        }
        public ActionResult AddSampleDetails(List <sample_detail> ci)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (pimsEntitiesNew dc = new pimsEntitiesNew())
                    {
                        foreach (var i in ci)
                        {
                            dc.sample_detail.Add(i);
                        }
                        dc.SaveChanges();
                        ModelState.Clear();
                        ViewBag.Message = "Data successfully saved!";

                        ci = new List <sample_detail> {
                            new sample_detail {
                                project_id = 0, gcl_id = "", sample_id = ""
                            }
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex;
            }
            return(View(ci));
        }
        public ActionResult Register(user user)
        {
            pimsEntitiesNew db = new pimsEntitiesNew();

            try
            {
                var item = db.users.SingleOrDefault(x => x.email == user.email);
                using (db)
                    if (ModelState.IsValid && item == null)
                    {
                        var password = Crypto.HashPassword(user.password);

                        user.password = password;
                        {
                            db.users.Add(user);
                            db.SaveChanges();
                        }
                        ModelState.Clear();
                        TempData["registerSuccessMessage"] = user.first_name + " " + user.last_name + " successfully registered.";
                    }
                    else
                    {
                        TempData["registerErrorMessage"] = "User already exist. Please use a different Email ID or contact the PIMS Administrator.";
                    }
            }
            catch (Exception e)
            {
                TempData["registerErrorMessage"] = e;
            }
            return(View("UserRegistered"));
        }
        public ActionResult SubmitNewProject(incoming_project newIncomingProject)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (pimsEntitiesNew db = new pimsEntitiesNew())
                    {
                        db.incoming_project.Add(newIncomingProject);
                        db.SaveChanges();
                    }
                    ModelState.Clear();

                    using (pimsEntitiesNew dbpid = new pimsEntitiesNew())
                    {
                        var crum = dbpid.incoming_project.Max(d => d.temp_project_id);
                        ViewBag.successMessage = "Temporary Project ID:" + crum.ToString() + "\nYour project information has been successfully submitted.\nPlease bring your samples to the GCL along with the Temporary Project ID.";
                    }
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("projectSubmitError", ex.Message);
            }
            return(View());
        }
        public ActionResult ChangePassword(user user)
        {
            pimsEntitiesNew db          = new pimsEntitiesNew();
            string          newPassword = Crypto.HashPassword(user.password);

            user.password = newPassword;
            try
            {
                if (ModelState.IsValid)

                {
                    db.Entry(user).State = EntityState.Modified;
                    db.SaveChanges();
                }

                TempData["EditProfileMessage"] = "Profile Successfully updated!";
            }
            catch (Exception ex)
            {
                ViewBag.Error = "Error updating the user. Please make sure all fields have valid data.";
                return(RedirectToAction("ChangePassword"));
            }

            return(View("Index"));
        }
Example #6
0
        public ActionResult DeleteUser(int id)
        {
            pimsEntitiesNew db           = new pimsEntitiesNew();
            user            userToDelete = db.users.Find(id);

            db.users.Remove(userToDelete);
            db.SaveChanges();
            return(RedirectToAction("ManageUsers"));
        }
        /// <summary>
        /// Method to show create partial view of all the Sequencing projects data.
        /// </summary>
        public PartialViewResult sequencingTrack()
        {
            pimsEntitiesNew dc = new pimsEntitiesNew();

            // dc.Configuration.LazyLoadingEnabled = false; // if your table is relational, contain foreign key
            var data = dc.sequencing_data.ToList();


            return(PartialView("_sequencingTrack", data));
        }
        /// <summary>
        /// Method to show create partial view of all the Library Prep projects data.
        /// </summary>
        public PartialViewResult LibraryPrepTrack()
        {
            pimsEntitiesNew dc = new pimsEntitiesNew();

            // dc.Configuration.LazyLoadingEnabled = false; // if your table is relational, contain foreign key
            var data = dc.library_prep.ToList();


            return(PartialView("_LibraryPrepTrack", data));
        }
 public ActionResult Register(user user)
 {
     if (ModelState.IsValid)
     {
         using (pimsEntitiesNew db = new pimsEntitiesNew())
         {
             db.users.Add(user);
             db.SaveChanges();
         }
         ModelState.Clear();
         ViewBag.Message = user.first_name + " " + user.last_name + " successfully registered.";
     }
     return(View());
 }
Example #10
0
        public ActionResult DeleteUser(int?id)
        {
            pimsEntitiesNew db = new pimsEntitiesNew();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            user user = db.users.Find(id);

            if (user == null)
            {
                return(HttpNotFound());
            }
            return(View(user));
        }
        public ActionResult Login(user user)
        {
            using (pimsEntitiesNew db = new pimsEntitiesNew())
            {
                var usr = db.users.Single(u => u.email == user.email && u.password == user.password);

                if (usr != null)
                {
                    Session["email"]  = user.email.ToString();
                    Session["userID"] = user.user_id.ToString();
                    return(RedirectToAction("LoggedIn"));
                }

                else
                {
                    ModelState.AddModelError("", "Invalid username or password. Please try again.");
                }
            }
            return(View());
        }
Example #12
0
        public PartialViewResult showSamples(FormCollection fc)
        {
            int                  id      = Convert.ToInt32(fc["searchProjectId"]);
            pimsEntitiesNew      db      = new pimsEntitiesNew();
            List <sample_detail> samples = new List <sample_detail>();

            try
            {
                samples = db.sample_detail
                          .Where(s => s.project_id == id).ToList();

                if (samples.Count() == 0)
                {
                    ViewBag.Error = "No samples found for this project";
                }
            }catch (Exception e)
            {
                ViewBag.Error = "No samples found for this project";
            }
            return(PartialView("_SampleData", samples));
        }
        public ActionResult UploadFile(HttpPostedFileBase fileIn)
        {
            try
            {
                if (Request != null)
                {
                    HttpPostedFileBase file = Request.Files["UploadedFile"];
                    DataSet            ds   = new DataSet();

                    if ((file != null) && (file.ContentLength > 0))
                    {
                        string fileExtension = System.IO.Path.GetExtension(file.FileName);

                        if (fileExtension == ".xls" || fileExtension == ".xlsx")
                        {
                            string fileName        = file.FileName;
                            string fileContentType = file.ContentType;
                            byte[] fileBytes       = new byte[file.ContentLength];
                            var    data            = file.InputStream.Read(fileBytes, 0, Convert.ToInt32(file.ContentLength));
                            var    sampleList      = new List <sample_detail>();
                            using (var package = new ExcelPackage(file.InputStream))
                            {
                                var currentSheet = package.Workbook.Worksheets;
                                var workSheet    = currentSheet.First();
                                var noOfCol      = workSheet.Dimension.End.Column;
                                var noOfRow      = workSheet.Dimension.End.Row;

                                for (int rowIterator = 2; rowIterator <= noOfRow; rowIterator++)
                                {
                                    var sample = new sample_detail();
                                    sample.project_id = int.Parse(workSheet.Cells[rowIterator, 1].Value.ToString());
                                    sample.gcl_id     = workSheet.Cells[rowIterator, 2].Value.ToString();
                                    sample.sample_id  = workSheet.Cells[rowIterator, 3].Value.ToString();

                                    sampleList.Add(sample);
                                }

                                foreach (var i in sampleList)
                                {
                                    if (ModelState.IsValid)
                                    {
                                        using (pimsEntitiesNew db = new pimsEntitiesNew())
                                        {
                                            sample_detail newsample = new sample_detail();

                                            newsample.project_id = i.project_id;
                                            newsample.gcl_id     = i.gcl_id;
                                            newsample.sample_id  = i.sample_id;

                                            db.sample_detail.Add(newsample);
                                            db.SaveChanges();
                                        }
                                    }
                                }
                                ModelState.Clear();

                                ViewBag.Message = "File data successfully updated!";
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ViewBag.Error = "Make sure that GCL ID for samples are unique.\nAll Fields must have values and correct Datatypes.";
            }

            return(View("UploadFile"));
        }
        public ActionResult Login(user user)
        {
            pimsEntitiesNew db = new pimsEntitiesNew();

            var userPassword = "";
            var userPass     = (from d in db.users.Where(u => u.email == user.email)
                                select d.password).ToArray();

            if (userPass.Length == 0 || userPass.Length > 1)
            {
                ModelState.AddModelError("", "Invalid username or password. Please try again.");
                return(View());
            }

            if (userPass[0] != null)
            {
                userPassword = userPass[0];
            }


            var verifyPassword = false;

            if (userPassword != null)
            {
                verifyPassword = Crypto.VerifyHashedPassword(userPassword, user.password);
            }

            else
            {
                ModelState.AddModelError("", "Invalid username or password. Please try again.");
            }


            if (verifyPassword != false)
            {
                try
                {
                    var usr = db.users.Single(u => u.email == user.email && verifyPassword != false);

                    var id            = db.users.Where(p => p.email == user.email).Select(p => p.user_id).ToArray();
                    var userFirstName = db.users.Where(p => p.email == user.email).Select(p => p.first_name).ToArray();
                    var userLastName  = db.users.Where(p => p.email == user.email).Select(p => p.last_name).ToArray();
                    var userType      = db.users.Where(p => p.email == user.email).Select(p => p.user_type).ToArray();

                    if (usr != null)
                    {
                        Session["userID"]    = id[0];
                        Session["userType"]  = userType[0].ToString();
                        Session["firstName"] = userFirstName[0].ToString();
                        Session["lastName"]  = userLastName[0].ToString();
                        Session["fullName"]  = userFirstName[0].ToString() + " " + userLastName[0].ToString();
                        return(RedirectToAction("Index"));
                    }

                    else
                    {
                        ModelState.AddModelError("", "Invalid username or password. Please try again.");
                    }
                }
                catch (InvalidOperationException e)
                {
                    ModelState.AddModelError("", "Invalid username or password. Please try again.");
                }
            }
            else
            {
                ModelState.AddModelError("", "Invalid username or password. Please try again.");
            }

            return(View());
        }
        public PartialViewResult TurnAround()
        {
            pimsEntitiesNew db = new pimsEntitiesNew();
            var             queryExtraction = from d in db.new_project
                                              .Where(d => d.service_requested == "Extraction" &&
                                                     d.date_completed.HasValue && d.date_completed.Value.Year != 0001)
                                              select d;
            int extractionSum   = 0;
            int extractionCount = 0;

            foreach (new_project p in queryExtraction)
            {
                DateTime start      = p.date_submitted;
                DateTime finish     = p.date_completed.Value;
                TimeSpan difference = finish - start;

                int diff = difference.Days;

                extractionSum   += diff;
                extractionCount += 1;
            }
            if (extractionCount == 0)
            {
                extractionCount = 1;
            }
            double extractionAverage = extractionSum / extractionCount;

            Session["averageExtractionTAT"] = extractionAverage;


            var queryLibPrep = from d in db.new_project
                               .Where(d => d.service_requested == "Library Preparation" &&
                                      d.date_completed.HasValue && d.date_completed.Value.Year != 0001)
                               select d;
            int LibSum   = 0;
            int Libcount = 0;

            foreach (new_project p in queryLibPrep)
            {
                DateTime start      = p.date_submitted;
                DateTime finish     = p.date_completed.Value;
                TimeSpan difference = finish - start;

                int diff = difference.Days;

                LibSum   += diff;
                Libcount += 1;
            }

            double LibAverage = LibSum / Libcount;

            Session["LibraryPrepTAT"] = LibAverage;



            var queryCapture = from d in db.new_project
                               .Where(d => d.service_requested == "Library Capture" &&
                                      d.date_completed.HasValue && d.date_completed.Value.Year != 0001)
                               select d;
            int captureSum   = 0;
            int captureCount = 0;

            foreach (new_project p in queryCapture)
            {
                DateTime start      = p.date_submitted;
                DateTime finish     = p.date_completed.Value;
                TimeSpan difference = finish - start;

                int diff = difference.Days;

                captureSum   += diff;
                captureCount += 1;
            }
            if (captureCount == 0)
            {
                captureCount = 1;
            }

            double captureAverage = captureSum / captureCount;

            Session["captureTAT"] = captureAverage;



            var querySeq = from d in db.new_project
                           .Where(d => d.service_requested == "Sequencing" &&
                                  d.date_completed.HasValue && d.date_completed.Value.Year != 0001)
                           select d;
            int seqSum   = 0;
            int seqCount = 0;

            foreach (new_project p in querySeq)
            {
                DateTime start      = p.date_submitted;
                DateTime finish     = p.date_completed.Value;
                TimeSpan difference = finish - start;

                int diff = difference.Days;

                seqSum   += diff;
                seqCount += 1;
            }
            if (seqCount == 0)
            {
                seqCount = 1;
            }
            double seqAverage = seqSum / seqCount;

            Session["sequencingTAT"] = seqAverage;

            return(PartialView("_TurnAroundTimes"));
        }