public ActionResult Edit(int id)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý thông tin liên hệ"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Thông tin liên hệ"), Url = Url.Action("Index")
            });
            var model = new EmailsModel();

            if (id > 0)
            {
                var service = WorkContext.Resolve <IEmailsService>();
                model = service.GetById(id);
            }
            var result = new ControlFormResult <EmailsModel>(model);

            result.Title                = this.T("Thông tin liên hệ");
            result.FormMethod           = FormMethod.Post;
            result.UpdateActionName     = "Update";
            result.ShowCancelButton     = false;
            result.ShowBoxHeader        = false;
            result.FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml;
            result.FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml;

            result.AddAction().HasText(this.T("Clear")).HasUrl(this.Url.Action("Edit", RouteData.Values.Merge(new { id = 0 }))).HasButtonStyle(ButtonStyle.Success);
            result.AddAction().HasText(this.T("Back")).HasUrl(this.Url.Action("Index")).HasButtonStyle(ButtonStyle.Danger);
            return(result);
        }
        public IActionResult saveEmail([FromBody] EmailsModel email)
        {
            if (email == null)
            {
                return(BadRequest());
            }

            var msg  = new Message <EmailsModel>();
            var data = DbClientFactory <MyEventsDBClient> .Instance.SaveEmail(email,
                                                                              configuration.GetSection("MySettings").GetSection("DbConnection").Value);

            if (data == "c200")
            {
                msg.IsSuccess = true;
                if (email.OrganizerId == 0)
                {
                    msg.ReturnMessage = "Email saved successfully";
                }
                else
                {
                    msg.ReturnMessage = "Email updated successfully";
                }
            }
            else if (data == "c203")
            {
                msg.IsSuccess     = false;
                msg.ReturnMessage = "This phone does not exist";
            }
            return(Ok(msg));
        }
예제 #3
0
        public static EmailsModel TranslateAsEmail(this SqlDataReader reader, bool isList = false)
        {
            if (!isList)
            {
                if (!reader.HasRows)
                {
                    return(null);
                }
                reader.Read();
            }
            var item = new EmailsModel();

            if (reader.IsColumnExists("Id"))
            {
                item.Id = SqlHelper.GetNullableInt32(reader, "Id");
            }

            if (reader.IsColumnExists("OrganizerId"))
            {
                item.OrganizerId = SqlHelper.GetNullableInt32(reader, "OrganizerId");
            }

            if (reader.IsColumnExists("Email"))
            {
                item.Email = SqlHelper.GetNullableString(reader, "Email");
            }

            return(item);
        }
예제 #4
0
        public async Task ReInviteUsers([FromBody] EmailsModel users, CancellationToken cancellationToken)
        {
            try
            {
                var emails = new List <ApplicationUser>();

                foreach (var email in users.Emails)
                {
                    var dbUser = await _operations.RepositoryManager.GetUserFromLoginAsync(email, cancellationToken);

                    if (dbUser == null)
                    {
                        throw new AdminControllerException($"The email address {email} has not been created.", null);
                    }
                    if (!dbUser.IsRegistered)
                    {
                        emails.Add(dbUser);
                    }

                    if (!dbUser.IsInvited)
                    {
                        dbUser.IsInvited = true;
                        await _operations.RepositoryManager.UpdateUserAsync(dbUser, cancellationToken);
                    }
                }

                await SendInvites(emails, cancellationToken);
            }
            catch (Exception ex)
            {
                throw new AdminControllerException($"Error re-inviting users: {ex.Message}", ex);
            }
        }
예제 #5
0
        public ActionResult SentBy(int?id)
        {
            var m = new EmailsModel {
                senderid = id
            };

            return(View("Index", m));
        }
예제 #6
0
        public ActionResult SentTo(int?id)
        {
            var m = new EmailsModel {
                peopleid = id
            };

            return(View("Index", m));
        }
예제 #7
0
        public void AddEmail(EmailsModel _EmailsModel)
        {
            _EmailsModel.EmailID = (short)((int)(from S in EmailsData.Descendants("Email") orderby(short) S.Element("EmailID") descending select(short) S.Element("EmailID")).FirstOrDefault() + 1);
            EmailsData.Root.Add(new XElement("Email", new XElement("EmailID", _EmailsModel.EmailID),
                                             new XElement("EmailTxt", _EmailsModel.EmailTxt),
                                             new XElement("EmailTypeID", _EmailsModel.EmailTypeID)));

            EmailsData.Save(HttpContext.Current.Server.MapPath("~/App_Data/emails.xml"));
        }
예제 #8
0
        public void EditEmails(EmailsModel _EmailsModel)
        {
            try
            {
                XElement node = EmailsData.Root.Elements("Email").Where(i => (int)i.Element("EmailID") == _EmailsModel.EmailID).FirstOrDefault();

                node.SetElementValue("EmailTxt", _EmailsModel.EmailTxt);
                node.SetElementValue("EmailTypeID", _EmailsModel.EmailTypeID);
                EmailsData.Save(HttpContext.Current.Server.MapPath("~/App_Data/emails.xml"));
            }
            catch (Exception)
            {
                throw new NotImplementedException();
            }
        }
예제 #9
0
        public ActionResult CreateEmail(EmailsModel _Emailmodel, string command, FormCollection fm, int emailtype)
        {
            Session["Edit/Delete"] = "Edit";
            var EmailContext  = new Contexts.EmailsContexts();
            var emailTypeName = EmailContext.GetEmailType(emailtype);

            ViewBag.Title  = (_Emailmodel.EmailID > 0 ? "Edit " : "Add ") + emailTypeName;
            ViewBag.Submit = _Emailmodel.EmailID > 0 ? "Update" : "Save";
            if (string.IsNullOrEmpty(command))
            {
                try
                {
                    if (ViewBag.Submit == "Save")
                    {
                        if (EmailContext.GetEmails().Where(x => x.EmailTxt.ToLower().Trim() == _Emailmodel.EmailTxt.ToLower().Trim() && x.EmailTypeID == emailtype).Count() > 0)
                        {
                            ModelState.AddModelError("EmailTxt", _Emailmodel.EmailTxt + " Email already exists.");
                            return(View(_Emailmodel));
                        }
                        _Emailmodel.EmailTypeID = emailtype;
                        EmailContext.AddEmail(_Emailmodel);
                        TempData["AlertMessage"] = emailTypeName + " details saved successfully.";
                    }
                    else
                    {
                        if (EmailContext.GetEmails().Where(x => x.EmailTxt.ToLower().Trim() == _Emailmodel.EmailTxt.ToLower().Trim() && x.EmailTypeID == emailtype && x.EmailID != _Emailmodel.EmailID).Count() > 0)
                        {
                            ModelState.AddModelError("EmailTxt", _Emailmodel.EmailTxt + " Email already exists.");
                            return(View(_Emailmodel));
                        }
                        EmailContext.EditEmails(_Emailmodel);
                        TempData["AlertMessage"] = emailTypeName + " details updated successfully.";
                    }
                }
                catch (Exception ex)
                {
                    TempData["AlertMessage"] = "Some error occured, Please try after some time. " + ex.Message.ToString();
                }
            }
            var rvd = new RouteValueDictionary();

            rvd.Add("Column", Request.QueryString["Column"] != null ? Request.QueryString["Column"].ToString() : "FirstName");
            rvd.Add("Direction", Request.QueryString["Direction"] != null ? Request.QueryString["Direction"].ToString() : "Ascending");
            rvd.Add("pagesize", Request.QueryString["pagesize"] != null ? Request.QueryString["pagesize"].ToString() : Models.Common._pageSize.ToString());
            rvd.Add("page", Request.QueryString["page"] != null ? Request.QueryString["page"].ToString() : Models.Common._currentPage.ToString());
            rvd.Add("emailtype", _Emailmodel.EmailTypeID == 0 ? emailtype : _Emailmodel.EmailTypeID);
            return(RedirectToAction("BlogEmailListing", "Emails", rvd));
        }
예제 #10
0
        /// <summary>
        /// Get all to emails
        /// </summary>
        /// <returns></returns>
        private SelectList GetAllToEmails()
        {
            var _emailContext = new Contexts.EmailsContexts();
            var list          = _emailContext.GetEmails().Where(x => x.EmailTypeID == 2).OrderBy(x => x.EmailTxt).Select(x => new EmailsModel()
            {
                EmailID  = x.EmailID,
                EmailTxt = x.EmailTxt
            }).ToList();
            var objEmail = new EmailsModel();

            objEmail.EmailTxt = "-- Select To Email --";
            objEmail.EmailID  = 0;
            list.Insert(0, objEmail);
            var objselectlist = new SelectList(list, "EmailID", "EmailTxt");

            return(objselectlist);
        }
예제 #11
0
        public ActionResult CreateEmail(int?Emailid, int emailtype)
        {
            var _EmailContext = new Contexts.EmailsContexts();
            var _EmailModel   = new EmailsModel();
            var emailTypeName = _EmailContext.GetEmailType(emailtype);

            ViewBag.Title  = (Emailid.HasValue ? "Edit " : "Add ") + emailTypeName;
            ViewBag.Submit = Emailid.HasValue && Emailid.Value > 0 ? "Update" : "Save";

            if (Emailid.HasValue && Emailid.Value > 0)
            {
                if (_EmailModel != null)
                {
                    _EmailModel = _EmailContext.GetEmails().Where(x => x.EmailID == Emailid).FirstOrDefault();
                }
            }
            return(View(_EmailModel));
        }
        public ActionResult Update(EmailsModel model)
        {
            if (!ModelState.IsValid)
            {
                return(new AjaxResult().Alert(T(Constants.Messages.InvalidModel)));
            }

            var       service = WorkContext.Resolve <IEmailsService>();
            EmailInfo item    = model.Id == 0 ? new EmailInfo() : service.GetById(model.Id);

            item.FullName    = model.FullName;
            item.PhoneNumber = model.PhoneNumber;
            item.Email       = model.Email;
            item.Notes       = model.Notes;
            item.IsBlocked   = model.IsBlocked;
            service.Save(item);

            return(new AjaxResult().NotifyMessage("UPDATE_ENTITY_COMPLETE").Alert(T("Đã cập nhật thành công.")));
        }
예제 #13
0
        public async Task DeleteUsers([FromBody] EmailsModel users, CancellationToken cancellationToken)
        {
            try
            {
                foreach (var email in users.Emails)
                {
                    var user = await _operations.RepositoryManager.GetUserFromLoginAsync(email, cancellationToken);

                    if (user != null)
                    {
                        await _operations.RepositoryManager.DeleteUserAsync(user, cancellationToken);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new AdminControllerException($"Error deleting users: {ex.Message}", ex);
            }
        }
예제 #14
0
        public async Task RevokeUsers([FromBody] EmailsModel users, CancellationToken cancellationToken)
        {
            try
            {
                foreach (var email in users.Emails)
                {
                    var appUser = await _operations.RepositoryManager.GetUserFromLoginAsync(email, cancellationToken);

                    if (appUser == null)
                    {
                        throw new AdminControllerException($"The email address {email} does not exist and cannot be revoked.", null);
                    }
                    appUser.IsEnabled = false;

                    await _operations.RepositoryManager.UpdateUserAsync(appUser, cancellationToken);
                }
            }
            catch (Exception ex)
            {
                throw new AdminControllerException($"Error revoking user permissions: {ex.Message}", ex);
            }
        }
예제 #15
0
        public ActionResult BlogEmailListing(int?emailtype, GridSortOptions gridSortOptions, int?pagetype, int?page, int?pagesize, FormCollection fm, string objresult)
        {
            var _objContext = new Contexts.EmailsContexts();

            ViewBag.Title = _objContext.GetEmailType(emailtype.Value) + " Listing";
            var _EmailsModel = new EmailsModel();

            #region Ajax Call
            if (objresult != null)
            {
                AjaxRequest objAjaxRequest = JsonConvert.DeserializeObject <AjaxRequest>(objresult);//Convert json String to object Model
                if (objAjaxRequest.ajaxcall != null && !string.IsNullOrEmpty(objAjaxRequest.ajaxcall) && objresult != null && !string.IsNullOrEmpty(objresult))
                {
                    if (objAjaxRequest.ajaxcall == "paging")       //Ajax Call type = paging i.e. Next|Previous|Back|Last
                    {
                        Session["pageNo"] = page;                  // stores the page no for status
                    }
                    else if (objAjaxRequest.ajaxcall == "sorting") //Ajax Call type = sorting i.e. column sorting Asc or Desc
                    {
                        page = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"].ToString()) : page);
                        Session["GridSortOption"] = gridSortOptions;
                        pagesize = (Session["PageSize"] != null ? Convert.ToInt32(Session["PageSize"].ToString()) : pagesize);
                    }
                    else if (objAjaxRequest.ajaxcall == "ddlPaging")//Ajax Call type = drop down paging i.e. drop down value 10, 25, 50, 100, ALL
                    {
                        Session["PageSize"]       = (Request.QueryString["pagesize"] != null ? Convert.ToInt32(Request.QueryString["pagesize"].ToString()) : pagesize);
                        Session["GridSortOption"] = gridSortOptions;
                        Session["pageNo"]         = page;
                    }
                    else if (objAjaxRequest.ajaxcall == "status")//Ajax Call type = status i.e. Active/Inactive
                    {
                        page            = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"].ToString()) : page);
                        gridSortOptions = (Session["GridSortOption"] != null ? Session["GridSortOption"] as GridSortOptions : gridSortOptions);
                    }
                    else if (objAjaxRequest.ajaxcall == "displayorder")//Ajax Call type = Display Order i.e. drop down values
                    {
                        page            = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"].ToString()) : page);
                        gridSortOptions = (Session["GridSortOption"] != null ? Session["GridSortOption"] as GridSortOptions : gridSortOptions);
                    }
                    objAjaxRequest.ajaxcall = null;; //remove parameter value
                }
            }
            #endregion Ajax Call
            //This section is used to retain the values of page , pagesize and gridsortoption on complete page post back(Edit, Dlete)
            if (!Request.IsAjaxRequest() && Session["Edit/Delete"] != null && !string.IsNullOrEmpty(Session["Edit/Delete"].ToString()))
            {
                pagesize               = (Session["PageSize"] != null ? Convert.ToInt32(Session["PageSize"]) : Models.Common._pageSize);
                page                   = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"]) : Models.Common._currentPage);
                gridSortOptions        = (Session["GridSortOption"] != null ? Session["GridSortOption"] as GridSortOptions : gridSortOptions);
                Session["Edit/Delete"] = null;
            }
            else if (!Request.IsAjaxRequest() && Session["Edit/Delete"] == null)
            {
                //gridSortOptions.Column = "CreateDate";
                Session["PageSize"]       = null;
                Session["pageNo"]         = null;
                Session["GridSortOption"] = null;
            }
            if (gridSortOptions.Column != null && gridSortOptions.Column == "EmailTxt")
            {
            }
            else
            {
                gridSortOptions.Column = "EmailTxt";
            }
            var pageSize = pagesize.HasValue ? pagesize.Value : Models.Common._pageSize;
            var Page     = page.HasValue ? page.Value : Models.Common._currentPage;
            TempData["pager"] = pagesize;
            var pagedViewModel = new PagedViewModel <EmailsModel>
            {
                ViewData          = ViewData,
                Query             = _objContext.GetEmail(emailtype).AsQueryable(),
                GridSortOptions   = gridSortOptions,
                DefaultSortColumn = "EmailTxt",
                Page     = Page,
                PageSize = pageSize,
            }.Setup();

            if (Request.IsAjaxRequest())                                 // check if request comes from ajax, then return Partial view
            {
                return(View("BlogEmailListingPartial", pagedViewModel)); // ("partial view name ")
            }
            else
            {
                return(View(pagedViewModel));
            }
        }
예제 #16
0
 public IResponse <object> PostPartnerIds(EmailsModel emailsModel)
 {
     return(Request.Post("/api/ClientAccountInformation/partnerIds")
            .AddJsonBody(emailsModel).Build().Execute <object>());
 }
예제 #17
0
 public ActionResult List(EmailsModel m)
 {
     UpdateModel(m.Pager);
     return(View(m));
 }
예제 #18
0
        public ActionResult Index()
        {
            var m = new EmailsModel();

            return(View(m));
        }