Exemplo n.º 1
0
        public ActionResult Edit(SMSLogViewModel model)
        {
            var urlRefer = Request["UrlReferrerEdit"];

            if (ModelState.IsValid)
            {
                if (Request["Submit"] == "Save")
                {
                    var SMSLog = SMSLogRepository.GetSMSLogById(model.Id);
                    AutoMapper.Mapper.Map(model, SMSLog);
                    SMSLog.ModifiedUserId = WebSecurity.CurrentUserId;
                    SMSLog.ModifiedDate   = DateTime.Now;
                    SMSLog.SentDate       = DateTime.Now;
                    SMSLogRepository.InsertSMSLog(SMSLog);
                    //send sms
                    Erp.BackOffice.Helpers.Common.SendSMS(SMSLog.Phone, SMSLog.Body);
                    TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.UpdateSuccess;
                    if (Request["IsPopup"] == "true" || Request["IsPopup"] == "True")
                    {
                        ViewBag.closePopup = "true";
                        model.Id           = SMSLog.Id;
                        ViewBag.urlRefer   = urlRefer;
                        return(View(model));
                    }
                    return(Redirect(urlRefer));
                }

                return(RedirectToAction("Edit", new { Id = model.Id }));
            }
            if (Request.UrlReferrer != null)
            {
                return(Redirect(Request.UrlReferrer.AbsoluteUri));
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public ActionResult Create(SMSLogViewModel model)
        {
            var urlRefer = Request["UrlReferrerCreate"];

            if (ModelState.IsValid)
            {
                var SMSLog = new Domain.Crm.Entities.SMSLog();
                AutoMapper.Mapper.Map(model, SMSLog);
                SMSLog.IsDeleted      = false;
                SMSLog.CreatedUserId  = WebSecurity.CurrentUserId;
                SMSLog.ModifiedUserId = WebSecurity.CurrentUserId;
                SMSLog.CreatedDate    = DateTime.Now;
                SMSLog.ModifiedDate   = DateTime.Now;
                SMSLog.SentDate       = DateTime.Now;
                SMSLog.Status         = "Đã gửi";
                SMSLogRepository.InsertSMSLog(SMSLog);
                TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess;
                //send sms

                Erp.BackOffice.Helpers.Common.SendSMS(SMSLog.Phone, SMSLog.Body);

                if (Request["IsPopup"] == "true" || Request["IsPopup"] == "True")
                {
                    ViewBag.closePopup = "true";
                    model.Id           = SMSLog.Id;
                    ViewBag.urlRefer   = urlRefer;
                    return(View(model));
                }
                return(Redirect(urlRefer));
            }
            return(RedirectToAction("Create"));
        }
Exemplo n.º 3
0
        public ViewResult Create(string TargetModule, int?TargetID)
        {
            var model = new SMSLogViewModel();

            model.TargetModule = TargetModule;
            model.TargetID     = TargetID;
            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult SendSMS(SMSLogViewModel model)
        {
            var urlRefer = Request["UrlReferrerDetail"];
            var smsLog   = SMSLogRepository.GetvwSMSLogById(model.Id);

            if (smsLog != null && !string.IsNullOrEmpty(smsLog.Phone))
            {
                Erp.BackOffice.Helpers.Common.SendSMS(smsLog.Phone, smsLog.Body);
                if (Request["IsPopup"] == "true" || Request["IsPopup"] == "True")
                {
                    ViewBag.closePopup = "true";
                    ViewBag.urlRefer   = urlRefer;
                    return(RedirectToAction("Detail", "SMSLog", new { area = "Crm", Id = model.Id, closePopup = "true" }));
                }
                return(Redirect(urlRefer));
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 5
0
        public ActionResult Edit(int?Id)
        {
            var SMSLog = SMSLogRepository.GetSMSLogById(Id.Value);

            if (SMSLog != null && SMSLog.IsDeleted != true)
            {
                var model = new SMSLogViewModel();
                AutoMapper.Mapper.Map(SMSLog, model);

                if (model.CreatedUserId != Erp.BackOffice.Helpers.Common.CurrentUser.Id && Erp.BackOffice.Helpers.Common.CurrentUser.UserTypeId != 1)
                {
                    TempData["FailedMessage"] = "NotOwner";
                    return(RedirectToAction("Index"));
                }
                return(View(model));
            }
            if (Request.UrlReferrer != null)
            {
                return(Redirect(Request.UrlReferrer.AbsoluteUri));
            }
            return(RedirectToAction("Index"));
        }