コード例 #1
0
        // GET: SendNotificationAdmin
        public ActionResult Notification(RequestTicketEmailViewModel requestTicketEmailViewModel)
        {
            try
            {
                if (!string.IsNullOrEmpty(requestTicketEmailViewModel.TrackingId))
                {
                    SendingEmailhelper sendingEmailhelper = new SendingEmailhelper();
                    sendingEmailhelper.Send(requestTicketEmailViewModel.TrackingId);
                }

                var controller = RouteData.Values["controller"].ToString();
                var action     = RouteData.Values["action"].ToString();

                if (Request.UrlReferrer != null)
                {
                    var    fullUrl           = Request.UrlReferrer.ToString();
                    var    questionMarkIndex = fullUrl.IndexOf('?');
                    string queryString       = null;
                    string url = fullUrl;
                    if (questionMarkIndex != -1) // There is a QueryString
                    {
                        url         = fullUrl.Substring(0, questionMarkIndex);
                        queryString = fullUrl.Substring(questionMarkIndex + 1);
                    }

                    // Arranges
                    var request     = new HttpRequest(null, url, queryString);
                    var response    = new HttpResponse(new StringWriter());
                    var httpContext = new HttpContext(request, response);

                    var routeData = RouteTable.Routes.GetRouteData(new HttpContextWrapper(httpContext));

                    // Extract the data
                    if (routeData != null)
                    {
                        var values         = routeData.Values;
                        var controllerName = values["controller"];
                        var actionName     = values["action"];
                        var areaName       = values["area"];

                        return(RedirectToAction(actionName.ToString(), controllerName.ToString(), new { trackingId = requestTicketEmailViewModel.TrackingId }));
                    }
                }

                return(RedirectToAction("Login", "Login"));
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
 public JsonResult TestConnection(RequestSmtp requestSmtp)
 {
     try
     {
         SendingEmailhelper testEmail = new SendingEmailhelper();
         var result = testEmail.TestEmail(Convert.ToString(Session["EmailId"]));
         if (result == "Successful")
         {
             return(Json(new { status = "Success" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { status = "Failed" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #3
0
        // GET: PasswordReset
        public async Task <ActionResult> Process(ForgotPasswordModel resetPasswordModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var result = _verify.ValidateEmailIdExists(resetPasswordModel.EmailId);

                    if (!result)
                    {
                        TempData["PasswordResetMessage"] = "In Valid EmailId";
                    }
                    else
                    {
                        SendingEmailhelper sendingEmailhelper = new SendingEmailhelper();
                        var generatecode   = GenerateHashSha256.ComputeSha256Hash(GenerateRandomNumbers.RandomNumbers(6));
                        var userId         = _userMaster.GetUserIdbyEmailId(Convert.ToString(resetPasswordModel.EmailId));
                        var count          = _verification.GetSentResetPasswordVerificationCount(userId);
                        var sentEmailCount = Convert.ToInt32(ConfigurationManager.AppSettings["MaxResetEmailCount"]);
                        if (count == sentEmailCount)
                        {
                            TempData["PasswordResetMessage"] = "You Have exceed Limit for Resetting Password";
                        }
                        else
                        {
                            _verification.SendResetVerificationToken(userId, generatecode);
                            TempData["PasswordResetMessage"] = "Email Sent to your Account";
                            await sendingEmailhelper.SendForgotPasswordVerificationEmailasync(resetPasswordModel.EmailId, generatecode, "ForgotPassword", userId.ToString());
                        }
                    }
                }
                return(View(resetPasswordModel));
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #4
0
        public async Task <ActionResult> Register(UsermasterView usermaster)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!this.IsCaptchaValid("Captcha is not valid"))
                    {
                        ModelState.AddModelError("", "Error: captcha is not valid.");
                        return(View(usermaster));
                    }

                    if (_iUserMaster.CheckUsernameExists(usermaster.UserName))
                    {
                        ModelState.AddModelError("", "UserName already exists");
                        return(View(usermaster));
                    }

                    if (_iUserMaster.CheckEmailIdExists(usermaster.EmailId))
                    {
                        ModelState.AddModelError("", "EmailId already exists");
                        return(View(usermaster));
                    }

                    if (_iUserMaster.CheckMobileNoExists(usermaster.MobileNo))
                    {
                        TempData["MessageCreateUsersErrors"] = "MobileNo Already Exists";
                    }

                    var autoUsermaster = AutoMapper.Mapper.Map <Usermaster>(usermaster);
                    var salt           = GenerateRandomNumbers.RandomNumbers(20);
                    var saltedpassword = GenerateHashSha512.Sha512(usermaster.Password, salt);

                    var userId = _iUserMaster.AddUser(autoUsermaster, saltedpassword, salt, Convert.ToInt16(StatusMain.Roles.User));
                    if (userId != -1)
                    {
                        var emailVerficationToken = GenerateHashSha256.ComputeSha256Hash((GenerateRandomNumbers.RandomNumbers(6)));
                        _verification.SendRegistrationVerificationToken(userId, emailVerficationToken);

                        SendingEmailhelper sendingEmailhelper = new SendingEmailhelper();
                        var name = string.Concat(usermaster.FirstName, usermaster.LastName);
                        await sendingEmailhelper.SendVerificationEmailasync(usermaster.EmailId, name, emailVerficationToken, "Registration", Convert.ToString(userId));

                        TempData["MessageRegistration"] = "Thank you. Your Registration has been completed successfully.";
                    }
                    else
                    {
                        TempData["ErrorRegistration"] = "Something Went Wrong While you are registering.Please try after sometime.";
                    }

                    return(RedirectToAction("Register", "Registration"));
                }
                else
                {
                    return(View("Register", usermaster));
                }
            }
            catch
            {
                throw;
            }
        }
コード例 #5
0
        public async Task <ActionResult> Create(TicketsUserViewModel ticketsViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var file          = Request.Files;
                    var generate      = new GenerateTicketNo();
                    var applicationNo =
                        generate.ApplicationNo(_category.GetCategoryCodeByCategoryId(ticketsViewModel.CategoryId));

                    var tickets = AutoMapper.Mapper.Map <Tickets>(ticketsViewModel);
                    tickets.TicketId       = 0;
                    tickets.CreatedDate    = DateTime.Now;
                    tickets.TrackingId     = applicationNo;
                    tickets.StatusAssigned = false;
                    tickets.UserId         = Convert.ToInt32(_sessionHandler.UserId);

                    var message       = AppendString(ticketsViewModel.Message);
                    var ticketDetails = new TicketDetails()
                    {
                        Subject         = ticketsViewModel.Subject,
                        Message         = message,
                        TicketDetailsId = 0
                    };

                    var attachments       = new Attachments();
                    var attachmentdetails = new AttachmentDetails();
                    // ReSharper disable once CollectionNeverQueried.Local
                    var listofattachments = new List <Attachments>();
                    // ReSharper disable once CollectionNeverQueried.Local
                    var listofattachmentdetails = new List <AttachmentDetails>();

                    for (int i = 0; i <= file.Count - 1; i++)
                    {
                        if (file[i] != null && file[i].ContentLength > 0)
                        {
                            string extension = Path.GetExtension(file[i].FileName);
                            attachments.UserId         = Convert.ToInt64(_sessionHandler.UserId);
                            attachments.AttachmentName = file[i].FileName;
                            attachments.AttachmentType = extension;
                            attachments.CreatedDate    = DateTime.Now;
                            var inputStream = file[i].InputStream;
                            if (inputStream != null)
                            {
                                using (var binaryReader = new BinaryReader(inputStream))
                                {
                                    byte[] fileSize = binaryReader.ReadBytes(count: file[i].ContentLength);
                                    attachmentdetails.AttachmentBytes = fileSize;
                                }
                            }

                            listofattachments.Add(attachments);
                            listofattachmentdetails.Add(attachmentdetails);
                        }
                    }

                    var ticketId = _tickets.AddTickets(Convert.ToInt64(_sessionHandler.UserId), tickets, ticketDetails, listofattachments,
                                                       listofattachmentdetails);

                    if (ticketId != -1)
                    {
                        TempData["MessageTicket"] = applicationNo + ' ' + CommonMessages.TicketSuccessMessages;

                        TicketHistoryHelper ticketHistoryHelper = new TicketHistoryHelper();
                        var ticketHistory = new TicketHistory();
                        ticketHistory.UserId       = Convert.ToInt32(_sessionHandler.UserId);
                        ticketHistory.Message      = ticketHistoryHelper.CreateMessage(tickets.PriorityId, tickets.CategoryId);
                        ticketHistory.CategoryId   = tickets.CategoryId;
                        ticketHistory.PriorityId   = tickets.PriorityId;
                        ticketHistory.StatusId     = Convert.ToInt16(StatusMain.Status.Open);
                        ticketHistory.ProcessDate  = DateTime.Now;
                        ticketHistory.TicketId     = ticketId;
                        ticketHistory.ActivitiesId = Convert.ToInt16(StatusMain.Activities.Created);
                        _ticketHistory.TicketHistory(ticketHistory);

                        SendingEmailhelper sendingEmailhelper = new SendingEmailhelper();
                        Task task1 = sendingEmailhelper.SendEmailasync(applicationNo);
                        await Task.WhenAll(task1);
                    }
                    else
                    {
                        TempData["ErrorMessageTicket"] = CommonMessages.TicketErrorMessages;
                    }

                    return(RedirectToAction("Create", "Ticket"));
                }
                else
                {
                    ticketsViewModel.ListofCategory = _category.GetAllActiveSelectListItemCategory();
                    ticketsViewModel.ListofPriority = _priority.GetAllPrioritySelectListItem();
                    return(View(ticketsViewModel));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }