public ActionResult Index()
        {
            try
            {
                int userType = 0;
                int UserId   = 0;
                if (Session["UserId"] != null)
                {
                    UserId   = Convert.ToInt32(Session["UserId"].ToString());
                    userType = Convert.ToInt32(Session["UserType"].ToString());
                }

                PlacementsViewModel model = new PlacementsViewModel();
                model.placementsFilterViewModel = new PlacementsFilterViewModel()
                {
                    client = userType == (int)Web.Models.Enums.UserType.ClientUser ? _userClientService.GetUserClients(UserId, 1) : _clientService.GetActiveInactiveOrderedList(),
                    placementTypeModels = _formTypeService.GetAll(),
                };

                return(View(model));
            }
            catch (Exception ex)
            {
                _errorLogService.Add(new ErrorLogModel()
                {
                    Page = "Placements/Index", CreatedBy = Convert.ToInt32(Session["UserId"]), CreateDate = DateTime.Now, ErrorText = ex.ToMessageAndCompleteStacktrace()
                });
                return(View(new PlacementsViewModel()
                {
                    ErrorMessage = "Sorry, An error occurred!"
                }));
            }
        }
예제 #2
0
 public ActionResult EditProfile()
 {
     try
     {
         if (Session["UserId"] != null)
         {
             ProfileViewModel profileViewModel = new ProfileViewModel();
             profileViewModel.UserId = Convert.ToInt32(Session["UserId"]);
             profileViewModel        = _userService.GetById(profileViewModel.UserId);
             return(View(profileViewModel));
         }
         else
         {
             return(RedirectToAction("Login", "Account"));
         }
     }
     catch (Exception ex)
     {
         _errorLogService.Add(new ErrorLogModel()
         {
             Page = "UserController/EditProfile", CreatedBy = Convert.ToInt32(Session["UserId"]), CreateDate = DateTime.Now, ErrorText = ex.ToMessageAndCompleteStacktrace()
         });
         return(View(new ProfileViewModel()
         {
             ErrorMessage = "Sorry, An error occurred!"
         }));
     }
 }
예제 #3
0
        public ResultModel SendForgotPasswordMail(string email)
        {
            ResultModel resultModel = new ResultModel();

            if (!string.IsNullOrEmpty(email))
            {
                bool isValidEmail = Util.ValidateEmail(email);
                if (isValidEmail)
                {
                    try
                    {
                        User user = _userRepo.GetByEmail(email);
                        if (user != null)
                        {
                            string baseUrl         = HttpContext.Current.Request.Url.AbsoluteUri.Replace("/Account/ForgotPassword", "");
                            string queryString     = baseUrl + "/Account/ResetPassword/" + "?" + Util.Encode("userId=" + user.UserID);
                            string subject         = "Forgot Password";
                            string dirpath         = HttpContext.Current.Server.MapPath("/EmailTemplate");
                            string xlsTemplatePath = dirpath + "/ForgotEmail.html";
                            string emailTemplate   = File.ReadAllText(xlsTemplatePath);
                            emailTemplate = emailTemplate.Replace("[url]", queryString);
                            emailTemplate = emailTemplate.Replace("[baseurl]", baseUrl);
                            EmailHelper.SendMail(email, subject, emailTemplate);
                            resultModel.IsSuccess = true;
                            resultModel.Message   = "Your reset password email has been sent to '" + email + "'.";
                        }
                        else
                        {
                            // Do code here.
                            resultModel.IsSuccess = false;
                            resultModel.Message   = "No User Found.";
                        }
                    }
                    catch (Exception ex)
                    {
                        resultModel.IsSuccess = false;
                        _errorLogService.Add(new ErrorLogModel()
                        {
                            Page = "UserService/SendForgotPasswordMail", CreatedBy = Convert.ToInt32(HttpContext.Current.Session["UserId"]), CreateDate = DateTime.Now, ErrorText = ex.ToMessageAndCompleteStacktrace()
                        });
                        resultModel.Message = "Sorry, there was an error while processing your request. Please try again later.";
                    }
                }
                else
                {
                    resultModel.IsSuccess = false;
                    resultModel.Message   = "Not a valid email format.";
                }
            }
            else
            {
                resultModel.IsSuccess = false;
                resultModel.Message   = "Email address can not be set Empty";
            }
            return(resultModel);
        }
예제 #4
0
 public ActionResult Login()
 {
     try
     {
         LoginViewModel loginViewModel = new LoginViewModel();
         loginViewModel.UserCookieCheck = true;
         System.Web.HttpCookie loginUserCookie = HttpContext.Request.Cookies.Get("loginUserCookie");
         if (loginUserCookie != null && loginUserCookie.HasKeys)
         {
             string emailaddress = loginUserCookie["emailaddress"];
             string password     = loginUserCookie["password"];
             if (!string.IsNullOrEmpty(emailaddress) && !string.IsNullOrEmpty(password))
             {
                 loginViewModel.Email           = emailaddress;
                 loginViewModel.Password        = password;
                 loginViewModel.UserCookieCheck = true;
             }
         }
         return(View(loginViewModel));
     }
     catch (Exception ex)
     {
         _errorLogService.Add(new ErrorLogModel()
         {
             Page = "AccountController/Login", CreatedBy = Convert.ToInt32(Session["UserId"]), CreateDate = DateTime.Now, ErrorText = ex.ToMessageAndCompleteStacktrace()
         });
         return(View(new LoginViewModel()
         {
             ErrorMessage = "Sorry, An error occurred!"
         }));
     }
 }
        public ActionResult Index()
        {
            try
            {
                int userType = 0;
                int UserId   = 0;
                if (Session["UserId"] != null)
                {
                    UserId   = Convert.ToInt32(Session["UserId"].ToString());
                    userType = Convert.ToInt32(Session["UserType"].ToString());
                }

                ManageDocumentViewModel manageDocumentViewModel = new ManageDocumentViewModel();
                manageDocumentViewModel.ManageDocumentFilterViewModel = new ManageDocumentFilterViewModel()
                {
                    documentViewModel = new DocumentViewModel(),
                    client            = userType == (int)Web.Models.Enums.UserType.ClientUser ? _userClientService.GetUserClients(UserId) : _clientService.GetAllClients(),
                    practiceArea      = _practiceAreaService.GetAllPracticeArea(),
                    categoryModels    = _categoryService.GetAll(),
                    formTypeModels    = _formTypeService.GetAll(),
                    documentType      = _codesService.GetAllByType("DOCTYPE"),
                    state             = _codesService.GetAllStateByType("STATE")
                };

                return(View(manageDocumentViewModel));
            }
            catch (Exception ex)
            {
                _errorLogService.Add(new ErrorLogModel()
                {
                    Page = "DocumentCenter/Index", CreatedBy = Convert.ToInt32(Session["UserId"]), CreateDate = DateTime.Now, ErrorText = ex.ToMessageAndCompleteStacktrace()
                });
                return(View(new ManageDocumentViewModel()
                {
                    ErrorMessage = "Sorry, An error occurred!"
                }));
            }
        }
예제 #6
0
        private void LogError(Exception ex)
        {
            try
            {
                ErrorLog erroLog = new ErrorLog();
                erroLog.ErrorLogMessage    = ex.Message;
                erroLog.ErrorLogCreateDate = DateTime.Now;
                erroLog.ErrorLogStackTrace = ex.StackTrace;

                errorLogService.Add(erroLog);
                errorLogService.SaveChanges();
            }
            catch
            {
            }
        }
예제 #7
0
 // GET: EncryptPassword
 public ActionResult Index()
 {
     try
     {
         IUserService userService = new UserService();
         userService.EncryptionPassword();
         return(View());
     }
     catch (Exception ex)
     {
         _errorLogService.Add(new ErrorLogModel()
         {
             Page = "EncryptPassword/Index", CreatedBy = Convert.ToInt32(Session["UserId"]), CreateDate = DateTime.Now, ErrorText = ex.ToMessageAndCompleteStacktrace()
         });
         return(View(ViewBag.ErrorMessage = "Sorry, An error occurred!"));
     }
 }
예제 #8
0
 public HttpResponseMessage Add(ErrorLogAddRequest model)
 {
     if (!ModelState.IsValid)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
     }
     try
     {
         ItemResponse <int> resp = new ItemResponse <int>();
         resp.Item = _errorService.Add(model);
         return(Request.CreateResponse(HttpStatusCode.OK, resp));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }
예제 #9
0
        public IHttpActionResult Post([FromBody] ERROR_LOG error_log)
        {
            if (!ModelState.IsValid || error_log == null)
            {
                string errors = "";
                foreach (var modelstate in ModelState.Values)
                {
                    foreach (var error in modelstate.Errors)
                    {
                        errors += "|" + error.ErrorMessage + "|" + error.Exception;
                    }
                }
                throw new BadInputException()
                      {
                          ExceptionMessage = errors
                      };
            }

            var result = _errorLogService.Add(error_log);

            return(Created("error log", result));
        }
예제 #10
0
        public void AddOrUpdate(ManageDocumentFilterViewModel manageDocumentFilterViewModel)
        {
            try
            {
                if (manageDocumentFilterViewModel.documentFile != null)
                {
                    var postedFile = manageDocumentFilterViewModel.documentFile;
                    if (postedFile != null && postedFile.ContentLength > 0)
                    {
                        string filePath = System.Web.HttpContext.Current.Server.MapPath("../Documents");
                        if (!File.Exists(filePath))
                        {
                            Directory.CreateDirectory(filePath);
                        }
                        string saveToPath = Path.Combine(filePath, postedFile.FileName);
                        postedFile.SaveAs(saveToPath);
                    }
                }
                if (manageDocumentFilterViewModel.documentViewModel.Id > 0)
                {
                    Document document = _documentSearchRepository.GetById(manageDocumentFilterViewModel.documentViewModel.Id);
                    document.StateCodeID    = manageDocumentFilterViewModel.documentViewModel.StateCodeId;
                    document.DocumentTypeID = manageDocumentFilterViewModel.documentViewModel.DocumentTypeId;
                    document.PracticeAreaID = manageDocumentFilterViewModel.documentViewModel.PracticeAreaId;
                    document.DocumentName   = manageDocumentFilterViewModel.documentViewModel.DocumentName;
                    document.Description    = manageDocumentFilterViewModel.documentViewModel.Description;
                    document.FileName       = manageDocumentFilterViewModel.documentFile != null ?manageDocumentFilterViewModel.documentFile.FileName : document.FileName;
                    _documentSearchRepository.Update(document);
                    _documentClientsRepo.DeleteByDocumentId(manageDocumentFilterViewModel.documentViewModel.Id);
                    if (manageDocumentFilterViewModel.documentViewModel.ClientId != null)
                    {
                        foreach (var itemId in manageDocumentFilterViewModel.documentViewModel.ClientId)
                        {
                            documentClient dClient = new documentClient()
                            {
                                documentID = manageDocumentFilterViewModel.documentViewModel.Id,
                                clientID   = Convert.ToInt32(itemId)
                            };
                            _documentClientsRepo.Add(dClient);
                        }
                    }

                    manageDocumentFilterViewModel.IsSuccess = true;
                    manageDocumentFilterViewModel.Message   = "Record Updated Successfully.";
                }
                else
                {
                    Document newDocument = new Document()
                    {
                        StateCodeID    = manageDocumentFilterViewModel.documentViewModel.StateCodeId,
                        DocumentTypeID = manageDocumentFilterViewModel.documentViewModel.DocumentTypeId,
                        PracticeAreaID = manageDocumentFilterViewModel.documentViewModel.PracticeAreaId,
                        DocumentName   = manageDocumentFilterViewModel.documentViewModel.DocumentName,
                        Description    = manageDocumentFilterViewModel.documentViewModel.Description,
                        FileName       = manageDocumentFilterViewModel.documentFile != null ? manageDocumentFilterViewModel.documentFile.FileName : null,
                    };
                    _documentSearchRepository.Add(newDocument);
                    if (newDocument.ID > 0 && (manageDocumentFilterViewModel.documentViewModel.ClientId != null))
                    {
                        foreach (var itemId in manageDocumentFilterViewModel.documentViewModel.ClientId)
                        {
                            documentClient dClient = new documentClient()
                            {
                                documentID = newDocument.ID,
                                clientID   = Convert.ToInt32(itemId)
                            };
                            _documentClientsRepo.Add(dClient);
                        }
                    }
                    manageDocumentFilterViewModel.IsSuccess = true;
                    manageDocumentFilterViewModel.Message   = "Record Inserted Successfully.";
                }
            }
            catch (Exception ex)
            {
                manageDocumentFilterViewModel.IsSuccess = false;
                manageDocumentFilterViewModel.Message   = "Sorry, An error occurred!.";
                _errorLogService.Add(new ErrorLogModel()
                {
                    Page = "DocumentSearchService/AddOrUpdate", CreatedBy = Convert.ToInt32(HttpContext.Current.Session["UserId"]), CreateDate = DateTime.Now, ErrorText = ex.ToMessageAndCompleteStacktrace()
                });
            }
        }