Exemplo n.º 1
0
        /// <summary>
        /// Adds the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <exception cref="NotImplementedException"></exception>
        public AttachmentNotificationSettingsModel Add(AttachmentNotificationSettingsModel model)
        {
            try
            {
                var entity = new AttachmentNotificationSettings()
                {
                    AttachmentId = model.AttachmentId,
                    ByEmail      = model.ByEmail,
                    ByText       = model.ByText,
                    WhenDownload = model.WhenDownload,
                    WhenExpired  = model.WhenExpired,
                    CreatedOn    = DateTime.Now,
                    UpdatedOn    = DateTime.Now
                };
                this.m_AttachmentNotificationSettingsRepository.Add(entity);
                this.AddNotificationDetails(model);

                return(model);
            }
            catch (Exception ex)
            {
                var message = string.Format("{0} {1} {2}", ex.InnerException == null ? ex.Message : ex.InnerException.Message, Environment.NewLine, ex.StackTrace);
                throw new Exception(message);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Adds the notification details.
 /// </summary>
 /// <param name="model">The model.</param>
 private void AddNotificationDetails(AttachmentNotificationSettingsModel model)
 {
     foreach (var item in model.notifyInfo)
     {
         NotificationDetails details = new NotificationDetails();
         details.AttachmentId      = model.AttachmentId;
         details.NotiicationSendOn = item.notifyText;
         details.type = model.ByEmail != false ? (int)NotificationDetailsEnum.Email : (int)NotificationDetailsEnum.Text;
         this.m_NotificationDetailsRepository.Add(details);
     }
 }
 public IActionResult Post([FromBody] AttachmentNotificationSettingsModel Request)
 {
     try
     {
         var response = this.m_Service.Add(Request);
         return(new OkObjectResult(response));
     }
     catch (Exception ex)
     {
         return(new BadRequestObjectResult(ex));
     }
 }
        public static AttachmentNotificationSettings MapNotification(AttachmentNotificationSettingsModel source)
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <AttachmentNotificationSettingsModel, AttachmentNotificationSettings>();
            });

            IMapper mapper = config.CreateMapper();

            var destination = mapper.Map <AttachmentNotificationSettingsModel, AttachmentNotificationSettings>(source);

            return(destination);
        }