Ejemplo n.º 1
0
        public JsonResult Edit(MailTemplateDto model)
        {
            string errs = GetModelStateError();

            if (!string.IsNullOrEmpty(errs))
            {
                return(Json(new OperateMessage <string>(OperateResult.Fail, true, errs)));
            }
            MailTemplateDto currModel = _MailTemplateAppService.Get(model.ID);

            if (currModel == null)
            {
                return(Json(new OperateMessage <string>(OperateResult.Fail, true, "修改失败,修改的内容不存在!")));
            }
            currModel.CallEnumKey      = model.CallEnumKey;
            currModel.Content          = model.Content;
            currModel.IsDefault        = model.IsDefault;
            currModel.LanguageTypeID   = model.LanguageTypeID;
            currModel.LastUpdateTime   = DateTime.Now;
            currModel.LastUpdateUserID = _currUser.ID;
            currModel.MailTitle        = model.MailTitle;
            currModel.Title            = model.Title;

            bool IsSucceed = _MailTemplateAppService.Edit(currModel);

            if (IsSucceed)
            {
                return(Json(new OperateMessage <string>("/MailTemplate/Index")));
            }
            return(Json(new OperateMessage <string>(IsSucceed ? OperateResult.Success : OperateResult.Fail, true, IsSucceed ? "修改成功!" : "修改失败!")));
        }
Ejemplo n.º 2
0
        public JsonResult Create(MailTemplateDto model)
        {
            string errs = GetModelStateError();

            if (!string.IsNullOrEmpty(errs))
            {
                return(Json(new OperateMessage <string>(OperateResult.Fail, true, errs)));
            }
            bool IsSucceed = _MailTemplateAppService.Create(new MailTemplateDto()
            {
                ID               = Guid.NewGuid(),
                CallEnumKey      = model.CallEnumKey,
                Content          = model.Content,
                CreateTime       = DateTime.Now,
                CreatorID        = _currUser.ID,
                LanguageTypeID   = model.LanguageTypeID,
                IsDefault        = model.IsDefault,
                LastUpdateTime   = DateTime.Now,
                LastUpdateUserID = _currUser.ID,
                MailTitle        = model.MailTitle,
                Title            = model.Title,
            });

            if (IsSucceed)
            {
                return(Json(new OperateMessage <string>("/MailTemplate/Index")));
            }
            return(Json(new OperateMessage <string>(IsSucceed ? OperateResult.Success : OperateResult.Fail, true, IsSucceed ? "添加成功!" : "添加失败!")));
        }
Ejemplo n.º 3
0
        public IActionResult Edit(Guid ID)
        {
            ViewBag.LangList = _languageTypeAppService.QueryList(a => a.ID != Guid.Empty);
            MailTemplateDto currModel = _MailTemplateAppService.Get(ID);

            return(View(currModel));
        }
        string SetTemplate(MailTemplateDto mailTemplate, string name, bool flag)
        {
            StringBuilder sb   = new StringBuilder();
            var           body = $"<p>{mailTemplate.Salut} {name}</p>{mailTemplate.Body}";

            sb.AppendFormat("<table width='100%'> <tbody> <tr bgColor='#f7f7f7'> <td align='center' height='90'> <img src='http://189.206.139.232/cdn/perti/logo.png' alt='logo'/> </td></tr><tr> <td> <br/><br/> {0} <br/><br/><br/><br/> </td></tr><tr> <td align='center'> <p style='margin:0'> <a href='https://www.facebook.com/GrupoPerTI/'><img src='http://189.206.139.232/CDN/perti/facebook.png' alt='facebook' width='30'/></a> <span>&nbsp;&nbsp;&nbsp;</span> <a href='https://www.linkedin.com/company/grupo-perti/?viewAsMember=true'><img src='http://189.206.139.232/CDN/perti/linkedin.png' alt='linkedin' width='30'/></a> <span>&nbsp;&nbsp;&nbsp;</span> <a href='https://www.grupoperti.com.mx'><img src='http://189.206.139.232/CDN/perti/link.png' alt='perti' width='25'/></a> </p><span>Enviado por Grupo PerTI</span> <p style='margin:0'> (55) 5543 6045 | <a href='mailto:[email protected]'>[email protected]</a> </p><br/> <p style='margin:0' align='center'> <img src='http://189.206.139.232/CDN/perti/footeremail.png' alt='footer email'/> </p></td></tr></tbody> </table>", body);
            return(sb.ToString());
        }
        public async Task <IActionResult> Post([FromBody] MailTemplateDto templateDto)
        {
            if (ModelState.IsValid)
            {
                var item = await _mailTemplateService.AddOrUpdateAsync(templateDto, CurrentUser.UserName);

                return(Ok(item));
            }

            return(NoContent());
        }
        public async Task <BaseResponse> AddOrUpdateAsync(MailTemplateDto mailTemplateDto, string userName)
        {
            var response = new BaseResponse();

            try
            {
                _mailTemplateRepository.UserName = userName;
                var mailTemplate = _mapper.Map <MailTemplate>(mailTemplateDto);
                if (string.IsNullOrEmpty(mailTemplate.Id))
                {
                    //validar el nombre del template page
                    var template = await _mailTemplateRepository.FindEntityBy(x => x.Name.Trim().ToLower() == mailTemplateDto.Name.Trim().ToLower());

                    if (template != null)
                    {
                        response.Message = LoggingEvents.INSERT_DUPLICATED_MESSAGE;
                        return(response);
                    }


                    mailTemplate.Id       = Common.Utilities.Utils.NewGuid;
                    mailTemplate.IsActive = true;
                    _mailTemplateRepository.Add(mailTemplate);
                    response.Message = LoggingEvents.INSERT_SUCCESS_MESSAGE;
                }
                else
                {
                    //validar el nombre del template page
                    var template = await _mailTemplateRepository.FindEntityBy(x => x.Name.Trim().ToLower() == mailTemplateDto.Name.Trim().ToLower() && x.Id != mailTemplateDto.Id);

                    if (template != null)
                    {
                        response.Message = LoggingEvents.INSERT_DUPLICATED_MESSAGE;
                        return(response);
                    }

                    _mailTemplateRepository.Edit(mailTemplate);
                    response.Message = LoggingEvents.UPDATE_SUCCESS_MESSAGE;
                }

                var item = await _mailTemplateRepository.SaveChanges();

                response.Success = true;
                response.Id      = mailTemplate.Id;
            }
            catch (System.Exception ex)
            {
                response.Message = LoggingEvents.INSERT_FAILED_MESSAGE;
                LoggerService.LogToFile(ex);
            }

            return(response);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// edit
 /// </summary>
 /// <param name="dto"></param>
 /// <returns></returns>
 public bool Edit(MailTemplateDto dto)
 {
     try
     {
         var entity = _repository.InsertOrUpdate(Mapper.Map <MailTemplate>(dto));
         return(entity == null ? false : true);
     }
     catch (Exception ex)
     {
         _log.LogError("MailTemplateAppService Edit error occured:" + ex.Message);
         return(false);
     }
 }
        public async Task <MailTemplateDto> GetByIdAsync(string id)
        {
            MailTemplateDto itemDto = null;

            try
            {
                var item = await _mailTemplateRepository.FindEntityAsNoTrackingBy(x => x.Id == id);

                itemDto = _mapper.Map <MailTemplateDto>(item);
            }
            catch (System.Exception ex)
            {
                LoggerService.LogToFile(ex);
            }

            return(itemDto);
        }