Ejemplo n.º 1
0
        public ActionResult ChangeStatus(int libId, int readerId, AbonentStatusEnum status)
        {
            if (!WebSecurity.IsAuthenticated)
            {
                RedirectToAction("Index", "Login");
            }
            int userId = WebSecurity.GetUserId(User.Identity.Name);

            var librarian = context.Librarians.FirstOrDefault(c => c.UserId == userId);

            if (librarian != null)
            {
                int librarianId         = librarian.Id;
                StatusChangeModel model = new StatusChangeModel
                {
                    LibraryId = libId,
                    ReaderId  = readerId,
                    Status    = status
                };

                IEnumerable <AbonentStatusEnum> values = Enum.GetValues(typeof(AbonentStatusEnum)).Cast <AbonentStatusEnum>();
                model.StatusList = values.Select(value => new SelectListItem
                {
                    Text  = Utils.Enums.GetDescription(value),
                    Value = value.ToString()
                });
                return(PartialView("~/Views/LibrarianPage/_ChangeAbonentStatus.cshtml", model));
            }

            return(RedirectToAction("Index", "LibrarianPage"));
        }
        public static void ChangeStatusLicense(StatusChangeModel newStatus)
        {
            var License = DbContext.db.License.Find(newStatus.IdLicense);

            newStatus.PrevStatus  = License.Status.Value;
            License.Status        = newStatus.CurrentStatus;
            newStatus.IdInspector = SecurityContext.IdUser;

            DbContext.db.License.Create();
            DbContext.db.HistoryStatusLicense.Add(newStatus);
            DbContext.db.SaveChanges();
        }
Ejemplo n.º 3
0
        public ActionResult ChangeStatus(StatusChangeModel model)
        {
            var result = librarianContext.ChangeStatusAbonent(model.LibraryId, model.ReaderId, (int)model.Status);

            if (result)
            {
                TempData["OperationStatus"] = true;
                TempData["OpearionMessage"] = "Статус успешно изменен";
            }
            else
            {
                TempData["OperationStatus"] = false;
                TempData["OpearionMessage"] = "Произошла ошибка при смене статуса";
            }

            return(RedirectToAction("Claims", "LibrarianPage"));
        }
Ejemplo n.º 4
0
        private void Change_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                StatusChangeModel status = new StatusChangeModel();

                status.DateChange    = DateTime.Today;
                status.Descriptoin   = Description.Text;
                status.IdLicense     = LogicLicense.GetId(License.Text);
                status.CurrentStatus = LogicStatusLicense.GetIdByName(StatusName.Text);

                LogicLicense.ChangeStatusLicense(status);
                MessageBox.Show("Статус лицензии успешно изменен!");

                InspectorMainWindow inspector = new InspectorMainWindow();
                inspector.Show();
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public IObservable <StatusModel> Stop()
        {
            return(Observable.Create <StatusModel>(subscriber =>
            {
                RestClient client = new RestClient(BuildBaseUrl());
                RestRequest request = new RestRequest();
                AddQueryParamsToRequest(request);

                IRestResponse response = client.Delete(request);

                if (!IsSuccessful(response))
                {
                    subscriber.OnError(new ServerResponseException());
                    return Disposable.Empty;
                }

                StatusChangeModel model = JsonConvert.DeserializeObject <StatusChangeModel>(response.Content);
                subscriber.OnNext(model.Status);
                subscriber.OnCompleted();

                return Disposable.Empty;
            }));
        }
        protected void btnSuspendMerchant_Click(object sender, EventArgs e)
        {
            try
            {
                using (ApplicationDbContext ctx = new ApplicationDbContext())
                {
                    int merchantId;
                    Int32.TryParse(hMerchantRecordId.Value, out merchantId);
                    string adminId = Context.User.Identity.GetUserId();

                    RadTextBox txtMerchantSuspensionNotes = (RadTextBox)StatusView.FindControl("txtMerchantSuspensionNotes");

                    if (ctx.Merchants.Any(m => m.RecordId == merchantId))
                    {
                        MerchantModel merchant = ctx.Merchants.First(m => m.RecordId == merchantId);
                        MerchantSuspensionModel suspension = new MerchantSuspensionModel();
                        Int32 reasonId = 0;
                        Int32.TryParse(ddlSuspendReasons.SelectedValue, out reasonId);

                        merchant.MerchantStatus = ctx.MerchantStatuses.First(ms => ms.StatusDescription == "Suspended");
                        suspension.Merchant = merchant;
                        suspension.OtherReasonNotes = txtMerchantSuspensionNotes.Text;
                        suspension.SuspendedBy = ctx.Users.First(u => u.Id == adminId);
                        suspension.SuspensionReason = ctx.MerchantSuspensionReasons.First(msr => msr.RecordId == reasonId);
                        suspension.Timestamp = DateTime.UtcNow;

                        ctx.MerchantSuspensions.Add(suspension);

                        ctx.SaveChanges();

                        StatusChangeModel statusChange = new StatusChangeModel
                        {
                            AdminUser = ctx.Users.First(u => u.Id == adminId),
                            Merchant = merchant,
                            MerchantStatus = merchant.MerchantStatus,
                            UnderwritingStatus = merchant.UnderwritingStatus,
                            Notes = suspension.SuspensionReason.ReasonName,
                            Timestamp = DateTime.UtcNow
                        };

                        ctx.StatusChanges.Add(statusChange);

                        ctx.SaveChanges();

                        //Send Email
                        Logic.Messaging messaging = new Logic.Messaging();
                        Boolean emailSent = false;
                        var template = messaging.GetTemplate("MerchantSuspended");

                        String suspendNotes = ddlSuspendReasons.SelectedText + ": " + txtMerchantSuspensionNotes.Text;

                        if (template != null)
                        {
                            String html = messaging.GetTemplateHtml(template);

                            foreach (EmailTemplateVariableModel variable in messaging.GetRequiredVariables(template))
                            {
                                if (merchant.MerchantPrincipal != null && merchant.MerchantPrincipal.Contact != null)
                                {
                                    if (variable.VariableName == "MERCHANT_FIRST_NAME")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", merchant.MerchantPrincipal.Contact.FirstName);
                                        html = html.Replace("<$" + variable.VariableName + ">", merchant.MerchantPrincipal.Contact.FirstName);
                                    }
                                    if (variable.VariableName == "MERCHANT_LAST_NAME")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", merchant.MerchantPrincipal.Contact.LastName);
                                        html = html.Replace("<$" + variable.VariableName + ">", merchant.MerchantPrincipal.Contact.LastName);
                                    }
                                }
                                else
                                {
                                    if (variable.VariableName == "MERCHANT_FIRST_NAME")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", "");
                                        html = html.Replace("<$" + variable.VariableName + ">", "");
                                    }
                                    if (variable.VariableName == "MERCHANT_LAST_NAME")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", "");
                                        html = html.Replace("<$" + variable.VariableName + ">", "");
                                    }
                                }
                                if (variable.VariableName == "MERCHANT_NAME")
                                {
                                    html = html.Replace("&lt;$" + variable.VariableName + "&gt;", merchant.CorpName);
                                    html = html.Replace("<$" + variable.VariableName + ">", merchant.CorpName);
                                }
                                if (merchant.Business.Address != null)
                                {
                                    if (variable.VariableName == "MERCHANT_ADDRESS")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", merchant.Business.Address.Address ?? "");
                                        html = html.Replace("<$" + variable.VariableName + ">", merchant.Business.Address.Address ?? "");
                                    }
                                    if (variable.VariableName == "MERCHANT_CITY")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", merchant.Business.Address.City ?? "");
                                        html = html.Replace("<$" + variable.VariableName + ">", merchant.Business.Address.City ?? "");
                                    }
                                    if (variable.VariableName == "MERCHANT_ZIP")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", merchant.Business.Address.Zip ?? "");
                                        html = html.Replace("<$" + variable.VariableName + ">", merchant.Business.Address.Zip ?? "");
                                    }
                                    if (merchant.Business.Address.State != null)
                                    {
                                        if (variable.VariableName == "MERCHANT_STATE")
                                        {
                                            html = html.Replace("&lt;$" + variable.VariableName + "&gt;", merchant.Business.Address.State.Name ?? "");
                                            html = html.Replace("<$" + variable.VariableName + ">", merchant.Business.Address.State.Name ?? "");
                                        }
                                    }
                                    else
                                    {
                                        if (variable.VariableName == "MERCHANT_STATE")
                                        {
                                            html = html.Replace("&lt;$" + variable.VariableName + "&gt;", "");
                                            html = html.Replace("<$" + variable.VariableName + ">", "");
                                        }
                                    }
                                }
                                else
                                {
                                    if (variable.VariableName == "MERCHANT_ADDRESS")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", "");
                                        html = html.Replace("<$" + variable.VariableName + ">", "");
                                    }
                                    if (variable.VariableName == "MERCHANT_CITY")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", "");
                                        html = html.Replace("<$" + variable.VariableName + ">", "");
                                    }
                                    if (variable.VariableName == "MERCHANT_STATE")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", "");
                                        html = html.Replace("<$" + variable.VariableName + ">", "");
                                    }
                                    if (variable.VariableName == "MERCHANT_ZIP")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", "");
                                        html = html.Replace("<$" + variable.VariableName + ">", "");
                                    }
                                }
                                if (variable.VariableName == "SUSPEND_NOTES")
                                {
                                    html = html.Replace("&lt;$" + variable.VariableName + "&gt;", suspendNotes);
                                    html = html.Replace("<$" + variable.VariableName + ">", suspendNotes);
                                }
                            }

                            if (ctx.Users.Any(u => u.Merchant.RecordId == merchant.RecordId))
                            {
                                IQueryable<ApplicationUser> userList = ctx.Users.Where(u => u.Merchant.RecordId == merchant.RecordId);

                                if (userList != null)
                                {
                                    foreach (ApplicationUser thisUser in userList)
                                    {
                                        if (html != null)
                                        {
                                            emailSent = messaging.SendEmail(thisUser.Email, template.EmailSubject, html, template, merchant, thisUser);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    lblMerchantActionMessage.Text = "Merchant Suspended Successfully.";

                    UpdateStatusLabel();

                    txtMerchantSuspensionNotes.Text = "";
                    ddlSuspendReasons.SelectedIndex = -1;

                }
            }
            catch (System.Exception ex)
            {
                lblMerchantActionMessage.Text = "Merchant was unable to be Suspeded.  Please contact your system administrator for more information.";
                _newLogic.WriteExceptionToDB(ex, "btnSuspendMerchant_Click");
            }
        }
        protected void btnApproveMerchant_Click(object sender, EventArgs e)
        {
            try
            {
                using (ApplicationDbContext ctx = new ApplicationDbContext())
                {
                    int merchantId;
                    Int32.TryParse(hMerchantRecordId.Value, out merchantId);
                    string adminId = Context.User.Identity.GetUserId();

                    RadTextBox txtMerchantApprovalNotes = (RadTextBox)StatusView.FindControl("txtMerchantApprovalNotes");

                    if (ctx.Merchants.Any(m => m.RecordId == merchantId))
                    {
                        MerchantModel merchant = ctx.Merchants.First(m => m.RecordId == merchantId);
                        Decimal approvedAdvanceAmount = 0;
                        Decimal.TryParse(txtApprovedAdvanceAmount.Text, out approvedAdvanceAmount);

                        merchant.MerchantStatus = ctx.MerchantStatuses.First(ms => ms.StatusDescription == "Active");
                        merchant.ApprovedBy = ctx.Users.First(u => u.Id == adminId);
                        merchant.ApprovalNotes = txtMerchantApprovalNotes.Text;
                        merchant.ApprovedDate = DateTime.UtcNow.Date;
                        merchant.ApprovedAdvanceAmount = approvedAdvanceAmount;
                        merchant.AvailableAdvanceAmount = approvedAdvanceAmount;

                        ctx.SaveChanges();

                        StatusChangeModel statusChange = new StatusChangeModel
                        {
                            AdminUser = ctx.Users.First(u => u.Id == adminId),
                            Merchant = merchant,
                            MerchantStatus = merchant.MerchantStatus,
                            UnderwritingStatus = merchant.UnderwritingStatus,
                            Notes = merchant.ApprovalNotes,
                            Timestamp = DateTime.UtcNow
                        };

                        ctx.StatusChanges.Add(statusChange);

                        ctx.SaveChanges();

                        //Send Email
                        Logic.Messaging messaging = new Logic.Messaging();
                        Boolean emailSent = false;
                        var template = messaging.GetTemplate("ApprovedEnrollment");

                        if (template != null)
                        {
                            String html = messaging.GetTemplateHtml(template);

                            foreach (EmailTemplateVariableModel variable in messaging.GetRequiredVariables(template))
                            {
                                if (merchant.MerchantPrincipal != null && merchant.MerchantPrincipal.Contact != null)
                                {
                                    if (variable.VariableName == "MERCHANT_FIRST_NAME")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", merchant.MerchantPrincipal.Contact.FirstName);
                                        html = html.Replace("<$" + variable.VariableName + ">", merchant.MerchantPrincipal.Contact.FirstName);
                                    }
                                    if (variable.VariableName == "MERCHANT_LAST_NAME")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", merchant.MerchantPrincipal.Contact.LastName);
                                        html = html.Replace("<$" + variable.VariableName + ">", merchant.MerchantPrincipal.Contact.LastName);
                                    }
                                }
                                else
                                {
                                    if (variable.VariableName == "MERCHANT_FIRST_NAME")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", "");
                                        html = html.Replace("<$" + variable.VariableName + ">", "");
                                    }
                                    if (variable.VariableName == "MERCHANT_LAST_NAME")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", "");
                                        html = html.Replace("<$" + variable.VariableName + ">", "");
                                    }
                                }
                                if (variable.VariableName == "MERCHANT_NAME")
                                {
                                    html = html.Replace("&lt;$" + variable.VariableName + "&gt;", merchant.CorpName);
                                    html = html.Replace("<$" + variable.VariableName + ">", merchant.CorpName);
                                }
                                if (merchant.Business.Address != null)
                                {
                                    if (variable.VariableName == "MERCHANT_ADDRESS")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", merchant.Business.Address.Address ?? "");
                                        html = html.Replace("<$" + variable.VariableName + ">", merchant.Business.Address.Address ?? "");
                                    }
                                    if (variable.VariableName == "MERCHANT_CITY")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", merchant.Business.Address.City ?? "");
                                        html = html.Replace("<$" + variable.VariableName + ">", merchant.Business.Address.City ?? "");
                                    }
                                    if (variable.VariableName == "MERCHANT_ZIP")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", merchant.Business.Address.Zip ?? "");
                                        html = html.Replace("<$" + variable.VariableName + ">", merchant.Business.Address.Zip ?? "");
                                    }
                                    if (merchant.Business.Address.State != null)
                                    {
                                        if (variable.VariableName == "MERCHANT_STATE")
                                        {
                                            html = html.Replace("&lt;$" + variable.VariableName + "&gt;", merchant.Business.Address.State.Name ?? "");
                                            html = html.Replace("<$" + variable.VariableName + ">", merchant.Business.Address.State.Name ?? "");
                                        }
                                    }
                                    else
                                    {
                                        if (variable.VariableName == "MERCHANT_STATE")
                                        {
                                            html = html.Replace("&lt;$" + variable.VariableName + "&gt;", "");
                                            html = html.Replace("<$" + variable.VariableName + ">", "");
                                        }
                                    }
                                }
                                else
                                {
                                    if (variable.VariableName == "MERCHANT_ADDRESS")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", "");
                                        html = html.Replace("<$" + variable.VariableName + ">", "");
                                    }
                                    if (variable.VariableName == "MERCHANT_CITY")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", "");
                                        html = html.Replace("<$" + variable.VariableName + ">", "");
                                    }
                                    if (variable.VariableName == "MERCHANT_STATE")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", "");
                                        html = html.Replace("<$" + variable.VariableName + ">", "");
                                    }
                                    if (variable.VariableName == "MERCHANT_ZIP")
                                    {
                                        html = html.Replace("&lt;$" + variable.VariableName + "&gt;", "");
                                        html = html.Replace("<$" + variable.VariableName + ">", "");
                                    }
                                }
                                if (variable.VariableName == "APPROVED_ADVANCE_AMOUNT")
                                {
                                    html = html.Replace("&lt;$" + variable.VariableName + "&gt;", merchant.ApprovedAdvanceAmount.ToString());
                                    html = html.Replace("<$" + variable.VariableName + ">", merchant.ApprovedAdvanceAmount.ToString());
                                }
                            }

                            if (ctx.Users.Any(u => u.Merchant.RecordId == merchant.RecordId))
                            {
                                IQueryable<ApplicationUser> userList = ctx.Users.Where(u => u.Merchant.RecordId == merchant.RecordId);

                                if (userList != null)
                                {
                                    foreach (ApplicationUser thisUser in userList)
                                    {
                                        if (html != null)
                                        {
                                            String newHtml = html.Replace("&lt;$USERNAME&gt;", thisUser.UserName);
                                            newHtml = newHtml.Replace("<$USERNAME>", thisUser.UserName);

                                            emailSent = messaging.SendEmail(thisUser.Email, template.EmailSubject, newHtml, template, merchant, thisUser);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    lblMerchantActionMessage.Text = "Merchant Approved Successfully.";

                    UpdateStatusLabel();
                }
            }
            catch (System.Exception ex)
            {
                lblMerchantActionMessage.Text = "Merchant was unable to be approved.  Please contact your system administrator for more information.";
                _newLogic.WriteExceptionToDB(ex, "btnApproveMerchant_Click");
            }
        }