Exemple #1
0
        public async Task <IHttpActionResult> PostNotificationFlight(ViewModels.NotificationX dto)
        {
            // return Ok(client);
            if (dto == null)
            {
                return(Exceptions.getNullException(ModelState));
            }
            if (!ModelState.IsValid)
            {
                return(Exceptions.getModelValidationException(ModelState));
            }
            var validate = unitOfWork.NotificationRepository.Validate(dto);

            if (validate.Code != HttpStatusCode.OK)
            {
                return(validate);
            }



            var result = await unitOfWork.FlightRepository.SendFlightSMS(dto);

            var saveResult = await unitOfWork.SaveAsync();

            if (saveResult.Code != HttpStatusCode.OK)
            {
                return(saveResult);
            }
            return(Ok(result));
        }
Exemple #2
0
        public virtual CustomActionResult Validate(ViewModels.NotificationX dto)
        {
            //var exist = dbSet.FirstOrDefault(q => q.Id != dto.Id && q.Title.ToLower().Trim() == dto.Title.ToLower().Trim());
            //if (exist != null)
            //    return Exceptions.getDuplicateException("Organization-01", "Title");

            return(new CustomActionResult(HttpStatusCode.OK, ""));
        }
Exemple #3
0
        public async Task <IHttpActionResult> PostNotification2(ViewModels.NotificationX dto)
        {
            // return Ok(client);
            if (dto == null)
            {
                return(Exceptions.getNullException(ModelState));
            }
            if (!ModelState.IsValid)
            {
                return(Exceptions.getModelValidationException(ModelState));
            }
            var validate = unitOfWork.NotificationRepository.Validate(dto);

            if (validate.Code != HttpStatusCode.OK)
            {
                return(validate);
            }

            //var newMessages = new List<string>();
            //int c = 0;
            //foreach (var x in dto.Employees)
            //{
            //    var entity = new Notification();
            //    unitOfWork.NotificationRepository.Insert(entity);
            //    ViewModels.NotificationX.Fill(entity, dto, x);
            //    if (dto.Names != null && dto.Names.Count > 0)
            //    {
            //        var name = dto.Names[c];

            //        newMessages.Add(entity.Message);

            //    }

            //    c++;


            //}



            var result = await unitOfWork.FlightRepository.SendPickup(dto);

            var saveResult = await unitOfWork.SaveAsync();

            if (saveResult.Code != HttpStatusCode.OK)
            {
                return(saveResult);
            }
            return(Ok(result));
        }
Exemple #4
0
        public async Task <IHttpActionResult> PostNotification(ViewModels.NotificationX dto)
        {
            // return Ok(client);
            if (dto == null)
            {
                return(Exceptions.getNullException(ModelState));
            }
            if (!ModelState.IsValid)
            {
                // return BadRequest(ModelState);
                return(Exceptions.getModelValidationException(ModelState));
            }
            var validate = unitOfWork.NotificationRepository.Validate(dto);

            if (validate.Code != HttpStatusCode.OK)
            {
                return(validate);
            }
            int c = 0;

            foreach (var x in dto.Employees)
            {
                var entity = new Notification();
                unitOfWork.NotificationRepository.Insert(entity);
                ViewModels.NotificationX.Fill(entity, dto, x);
                if (dto.Names != null && dto.Names.Count > 0)
                {
                    var name = dto.Names[c];
                    entity.Message = entity.Message.Replace("[#Name]", name);
                }

                c++;
            }



            var saveResult = await unitOfWork.SaveAsync();

            if (saveResult.Code != HttpStatusCode.OK)
            {
                return(saveResult);
            }



            return(Ok(dto));
        }
Exemple #5
0
 public static void FillDto(Models.Notification entity, ViewModels.NotificationX notification)
 {
     notification.Id             = entity.Id;
     notification.UserId         = entity.UserId;
     notification.CustomerId     = entity.CustomerId;
     notification.Message        = entity.Message;
     notification.DateSent       = DateTime.Now;
     notification.SenderId       = entity.SenderId;
     notification.SMS            = entity.SMS;
     notification.Email          = entity.Email;
     notification.App            = entity.App;
     notification.DateSMSSent    = null;
     notification.DateEmailSent  = null;
     notification.DateAppSent    = null;
     notification.SMSIssue       = null;
     notification.EmailIssue     = null;
     notification.AppIssue       = null;
     notification.DateAppVisited = null;
     notification.TypeId         = entity.TypeId;
     notification.Subject        = entity.Subject;
     notification.ModuleId       = entity.ModuleId;
 }
Exemple #6
0
 public static void Fill(Models.Notification entity, ViewModels.NotificationX notification, int userid)
 {
     entity.Id             = notification.Id;
     entity.UserId         = userid;
     entity.CustomerId     = notification.CustomerId;
     entity.Message        = notification.Message;
     entity.DateSent       = DateTime.Now;
     entity.SenderId       = notification.SenderId;
     entity.SMS            = notification.SMS;
     entity.Email          = notification.Email;
     entity.App            = notification.App;
     entity.DateSMSSent    = null;
     entity.DateEmailSent  = null;
     entity.DateAppSent    = null;
     entity.SMSIssue       = null;
     entity.EmailIssue     = null;
     entity.AppIssue       = null;
     entity.DateAppVisited = null;
     entity.TypeId         = notification.TypeId;
     entity.Subject        = notification.Subject;
     entity.ModuleId       = notification.ModuleId;
 }