// GET: Matters
        public async Task <ActionResult> Index()
        {
            //var matters = db.Matters.Include(m => m.Client);
            //return View(await matters.ToListAsync());

            try
            {
                var user    = User.Identity.Name;
                var email   = LegalGuideUtility.GetStaffEmailByLoginName(user);
                var staffId = LegalGuideUtility.GetStaffIdByEmail(email);
                if (string.IsNullOrEmpty(staffId))
                {
                    LegalGuideUtility.ErrorMessage = "Staff not Registered. Please Contact IT Department";
                    return(RedirectToAction("Error"));
                }
                if (HttpContext.User.IsInRole(LegalGuideUtility.ADMINISTRATOR))
                {
                    var mattersAdmin = db.Matters.Include(m => m.Client);
                    return(View(await mattersAdmin.ToListAsync()));
                }
                if (IsSelectedForTheCase(staffId))
                {
                    var mattersSelectedForCase = db.Matters.Include(m => m.Client);
                    return(View(await mattersSelectedForCase.ToListAsync()));
                }
                var matters = db.Matters.Include(m => m.Client);
                return(View(await matters.Where(x => x.CreatedBy.Equals(user)).ToListAsync()));
                //return View(await db.Matters.ToListAsync());
            }
            catch (Exception)
            {
                LegalGuideUtility.ErrorMessage = "Error Occured. Please Contact IT Department";
                return(RedirectToAction("Error"));
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,MatterNumber,DateHeared,CourtName,Location,StaffId,Status,AdvocateArgument,OpponentArgument,AdvocateNote,CreatedBy,CreatedOn,ModifiedBy,ModifiedOn,DateAdjourned,DefenseCounselName")] CourtActivity courtActivity)
        {
            if (ModelState.IsValid)
            {
                var user    = User.Identity.Name;
                var email   = LegalGuideUtility.GetStaffEmailByLoginName(user);
                var staffId = LegalGuideUtility.GetStaffIdByEmail(email);
                //courtActivity.CreatedBy
                courtActivity.ModifiedBy = user;
                courtActivity.ModifiedOn = DateTime.Today;
                courtActivity.StaffId    = staffId;

                db.Entry(courtActivity).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.Status = new List <SelectListItem> {
                new SelectListItem {
                    Value = "Adjourned", Text = "Adjourned"
                },
                new SelectListItem {
                    Value = "Dismissed", Text = "Dismissed"
                },
                new SelectListItem {
                    Value = "Judgement Delivered", Text = "Judgement Delivered"
                },
                new SelectListItem {
                    Value = "Strike Out", Text = "Strike Out"
                }
            };

            return(View(courtActivity));
        }
        public JsonResult GetMatterForEvents()
        {
            try
            {
                //var adminFileEvents
                db.Configuration.ProxyCreationEnabled = false;
                var user    = User.Identity.Name;
                var email   = LegalGuideUtility.GetStaffEmailByLoginName(user);
                var staffId = LegalGuideUtility.GetStaffIdByEmail(email);

                //var staffIdInStaffMatters = db.StaffMatters.Where(x => x.MatterNumber.Equals(LegalGuideUtility.MatterId)).Distinct();

                if (HttpContext.User.IsInRole(LegalGuideUtility.ADMINISTRATOR))
                {
                    var eventForAdmin          = db.Matters.ToList();
                    List <EventForView> events = new List <EventForView>();
                    foreach (var item in eventForAdmin)
                    {
                        events.Add(new EventForView
                        {
                            Title = item.Subject,
                            Start = (DateTime)item.FiledOn,
                            //End = (DateTime)item.DueDate,
                            Description = item.Description
                        });
                    }
                    return(Json(events, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    List <EventForView> events = new List <EventForView>();
                    var eventsForUser          = db.Matters.Where(x => x.CreatedBy.Equals(user) || IsSelectedForTheCase(staffId)).ToList();
                    foreach (var item in eventsForUser)
                    {
                        events.Add(new EventForView
                        {
                            Title = item.Subject,
                            Start = (DateTime)item.FiledOn,
                            //End = (DateTime)item.DueDate,
                            Description = item.Description
                        });
                    }
                    return(Json(events, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,ClientName,SoftwareVersion,ApprovedKey,ValidityFrom,ValidityTo,ApprovedDocument,ApprovedBy,CreatedBy,CreatedOn,ModifiedBy,ModifiedOn")] LicenseTable licenseTable, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    string fileName = string.Empty;
                    string filePath = string.Empty;

                    if (file.ContentLength > 0 && file != null)
                    {
                        filePath = file.FileName;
                        fileName = Path.GetFileName(file.FileName);
                    }
                    else
                    {
                        ViewBag.Error = " please select approved document to continue.";
                        return(View(licenseTable));
                    }
                    var folderPath   = AppDomain.CurrentDomain.BaseDirectory + "/App_Data/LicenseDocs";
                    var fullFilePath = Path.Combine(folderPath, filePath);
                    file.SaveAs(fullFilePath);

                    licenseTable.ApprovedDocument = fileName;
                    licenseTable.IsExpired        = false;
                    licenseTable.IsLicensed       = true;
                    licenseTable.ApprovedKey      = LegalGuideUtility.Encrypt(licenseTable.ApprovedKey);
                    licenseTable.SoftwareVersion  = licenseTable.SoftwareVersion.ToString();
                    licenseTable.CreatedBy        = User.Identity.Name;
                    licenseTable.CreatedOn        = DateTime.Today;
                    db.LicenseTables.Add(licenseTable);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    ViewBag.Error = "Can't Save License info please check and try again." + ex.Message;
                }
            }
            else
            {
                ViewBag.Error = "Can't Save License info, Some fields are missing";
                return(View(licenseTable));
            }

            return(View(licenseTable));
        }
Exemplo n.º 5
0
        public ActionResult GetStaffPassword(string password)
        {
            var user            = User.Identity.Name;
            var email           = LegalGuideUtility.GetStaffEmailByLoginName(user);
            var profilePassword = string.Empty;
            var staffRec        = db.Staffs.FirstOrDefault(x => x.EmailAddress.Equals(email));

            if (staffRec != null)
            {
                profilePassword = staffRec.Password;
            }
            if (profilePassword.Equals(password))
            {
                return(RedirectToAction("Create"));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
        public ActionResult Login(FormCollection model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            string username = model["txtUsername"];
            string password = model["txtPassword"];

            try
            {
                var dataItem = _context.LoginUsers.Where(x => x.Username.Equals(username) && x.Password.Equals(password)).First();
                if (dataItem == null)
                {
                    ViewBag.ErrorMsg = "Login Failed. Check Username/Password and try again.";
                    return(View());
                }
                if (dataItem != null)
                {
                    var userFullName = LegalGuideUtility.GetUserFullNameByLoginName(dataItem.Username);
                    ViewBag.FullName = userFullName;
                    LegalGuideUtility.UserFullName = userFullName;
                    FormsAuthentication.SetAuthCookie(dataItem.Username, false);
                    if (IsExpired(userFullName) == false && IsLicensed(userFullName) == true)
                    {
                        if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                            !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                        {
                            return(Redirect(returnUrl));
                        }
                        else
                        {
                            return(RedirectToLocal(returnUrl));
                        }
                    }
                    else if (LicenseType(userFullName).Equals("Trial"))
                    {
                        if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                            !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                        {
                            LegalGuideUtility.LicenseMessage = "Trial Period ends at " + TrialPeriod(userFullName);
                            return(Redirect(returnUrl));
                        }
                        else
                        {
                            //ViewBag.ErrorMsg = "Login Failed. Check Username/Password and try again.";
                            LegalGuideUtility.LicenseMessage = "Trial Period ends in " + TrialPeriod(userFullName) + " day(s)";
                            return(RedirectToLocal(returnUrl));
                        }
                    }
                    else
                    {
                        ViewBag.ErrorMsg = "Software is expired. Please contact IT Administrator.";
                        return(View());
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Invalid user/pass");
                    return(View());
                }
            }
            catch (Exception /*ex*/)
            {
                ViewBag.ErrorMsg = "Login failed. Username or Password not correct.";// + ex.Message;
                //return View();
            }
            return(View(model));
        }