Beispiel #1
0
        public ActionResult DeleteItem(string Id)
        {
            string     ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            NewsLetter model          = new NewsLetter()
            {
                Id = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString())
            };

            try
            {
                if (model.Id > 0)
                {
                    model.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    model.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    NewsLetterService.DeleteItem(model);
                    TempData["MessageSuccess"] = "Xóa thành công";
                    return(Json(new MsgSuccess()));
                }
                else
                {
                    TempData["MessageError"] = "Xóa Không thành công";
                    return(Json(new MsgError()));
                }
            }
            catch {
                TempData["MessageSuccess"] = "Xóa không thành công";
                return(Json(new MsgError()));
            }
        }
Beispiel #2
0
        private async Task <Response> SaveNewsletter()
        {
            var settings = this.Bind <NewletterSettings>();

            var valid = this.Validate(settings);

            if (!valid.IsValid)
            {
                var error = valid.SendJsonError();
                Log.Info("Error validating Newsletter settings, message: {0}", error.Message);
                return(Response.AsJson(error));
            }

            // Make sure emails are setup
            var emailSettings = await EmailService.GetSettingsAsync();

            if (!emailSettings.Enabled)
            {
                return(Response.AsJson(new JsonResponseModel {
                    Result = false, Message = "Please enable your email notifications"
                }));
            }

            settings.SendRecentlyAddedEmail = settings.SendRecentlyAddedEmail;
            var result = NewsLetterService.SaveSettings(settings);

            Log.Info("Saved headphones settings, result: {0}", result);
            return(Response.AsJson(result
                ? new JsonResponseModel {
                Result = true, Message = "Successfully Updated the Settings for Newsletter!"
            }
                : new JsonResponseModel {
                Result = false, Message = "Could not update the settings, take a look at the logs."
            }));
        }
Beispiel #3
0
        public ActionResult SaveItem(NewsLetter model)
        {
            string          ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int             IdDC           = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            NewsLetterModel data           = new NewsLetterModel()
            {
                Item = model
            };

            if (ModelState.IsValid)
            {
                if (model.Id == IdDC)
                {
                    model.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    model.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    NewsLetterService.SaveItem(model);
                    if (model.Id > 0)
                    {
                        TempData["MessageSuccess"] = "Cập nhật thành công";
                    }
                    else
                    {
                        TempData["MessageSuccess"] = "Thêm mới thành công";
                    }
                    return(RedirectToAction("Index"));
                }
            }
            return(View(data));
        }
Beispiel #4
0
        public ActionResult UpdateStatus([FromQuery] string Ids, Boolean Status)
        {
            string     ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            NewsLetter item           = new NewsLetter()
            {
                Id = Int32.Parse(MyModels.Decode(Ids, API.Models.Settings.SecretId + ControllerName).ToString()), Status = Status
            };

            try
            {
                if (item.Id > 0)
                {
                    item.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    dynamic UpdateStatus = NewsLetterService.UpdateStatus(item);
                    TempData["MessageSuccess"] = "Cập nhật Trạng Thái thành công";
                    return(Json(new MsgSuccess()));
                }
                else
                {
                    TempData["MessageError"] = "Cập nhật Trạng Thái Không thành công";
                    return(Json(new MsgError()));
                }
            }
            catch
            {
                TempData["MessageSuccess"] = "Cập nhật Trạng Thái không thành công";
                return(Json(new MsgError()));
            }
        }
Beispiel #5
0
        public IActionResult Index([FromQuery] SearchNewsLetter dto)
        {
            int             TotalItems     = 0;
            string          ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            NewsLetterModel data           = new NewsLetterModel()
            {
                SearchData = dto
            };

            data.ListItems = NewsLetterService.GetListPagination(data.SearchData, API.Models.Settings.SecretId + ControllerName);
            if (data.ListItems != null && data.ListItems.Count() > 0)
            {
                TotalItems = data.ListItems[0].TotalRows;
            }
            data.Pagination = new Models.Partial.PartialPagination()
            {
                CurrentPage = data.SearchData.CurrentPage, ItemsPerPage = data.SearchData.ItemsPerPage, TotalItems = TotalItems, QueryString = Request.QueryString.ToString()
            };

            return(View(data));
        }
Beispiel #6
0
        public ActionResult Register(PilotSignupModel model)
        {
            String message = @"";

            if (ModelState.IsValid)
            {
                // Attempt to add to news letter pilot signup
                PilotSignupStatus createStatus = new NewsLetterService().CreateOrUpdate(model.Email);

                if (createStatus == PilotSignupStatus.Success)
                {
                    //success
                    message = @"Thank you for signing up.";
                }
                else
                {
                    //fail
                }
            }

            return(RedirectToAction("Index", "Home", new { message = message }));
        }
Beispiel #7
0
        public IActionResult SaveItem(string Id = null)
        {
            NewsLetterModel data           = new NewsLetterModel();
            string          ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int             IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchNewsLetter()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            if (IdDC == 0)
            {
                data.Item = new NewsLetter();
            }
            else
            {
                data.Item = NewsLetterService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }


            return(View(data));
        }
Beispiel #8
0
        private Response SaveNewsletter()
        {
            var settings = this.Bind <NewletterSettings>();

            var valid = this.Validate(settings);

            if (!valid.IsValid)
            {
                var error = valid.SendJsonError();
                Log.Info("Error validating Headphones settings, message: {0}", error.Message);
                return(Response.AsJson(error));
            }
            settings.SendRecentlyAddedEmail = settings.SendRecentlyAddedEmail;
            var result = NewsLetterService.SaveSettings(settings);

            Log.Info("Saved headphones settings, result: {0}", result);
            return(Response.AsJson(result
                ? new JsonResponseModel {
                Result = true, Message = "Successfully Updated the Settings for Newsletter!"
            }
                : new JsonResponseModel {
                Result = false, Message = "Could not update the settings, take a look at the logs."
            }));
        }
 public static void ClassInit(TestContext textContext)
 {
     domainService            = new NewsLetterService();
     domainService.UnitOfWork = UnitOfWorkGenerator.MockUnitOfWork();
     AutoMapperInit.BuildMap();
 }
Beispiel #10
0
        private Negotiator Newsletter()
        {
            var settings = NewsLetterService.GetSettings();

            return(View["NewsletterSettings", settings]);
        }
Beispiel #11
0
        private async Task <Negotiator> Newsletter()
        {
            var settings = await NewsLetterService.GetSettingsAsync();

            return(View["NewsletterSettings", settings]);
        }
Beispiel #12
0
        public ActionResult BetaUserList()
        {
            var viewModel = new NewsLetterService().GetAll();

            return(View("Dashboard", viewModel));
        }