public EfAlerts ToEntity(AlertJson domainObject)
        {
            var entity = new EfAlerts();

            FillEntity(entity, domainObject);
            return(entity);
        }
Пример #2
0
        public JsonResult GetActive()
        {
            AlertJson alertView   = new AlertJson();
            var       alerts      = db.Alerts.Where(a => a.AlertStatus == Alert.Status.Ongoing);
            var       alertsQuery = from a in db.Alerts
                                    where a.AlertStatus == Alert.Status.Ongoing
                                    select a;
            List <Alert> alersList = alertsQuery.ToList();

            if (alersList.Count == 1)
            {
                Alert alert = alersList[0];
                alertView.Active  = true;
                alertView.Title   = alert.Title;
                alertView.Message = alert.Message;
                alertView.Status  = "Ongoing";
                if (alert.PublishingTime.HasValue)
                {
                    alertView.PublishingTime = alert.PublishingTime.Value.ToString();
                }
                else
                {
                    alertView.PublishingTime = DateTime.Now.ToString();
                }
            }
            else
            {
                alertView.Active = false;
            }

            return(Json(alertView));
        }
 public void FillEntity(EfAlerts entity, AlertJson domainObject)
 {
     entity.ID            = Guid.Parse(domainObject.ID);
     entity.Title         = domainObject.Title;
     entity.UserID        = Guid.Parse(domainObject.UserID);
     entity.AlarmDate     = DateTime.Parse(domainObject.AlarmDate);
     entity.AlarmTarikh   = domainObject.AlarmTarikh;
     entity.SaatErsal     = domainObject.SaatErsal;
     entity.AlarmType     = int.Parse(domainObject.AlarmType);
     entity.MeetingId     = Guid.Parse(domainObject.MeetingId);
     entity.IsSent        = bool.Parse(domainObject.IsSent);
     entity.SendStatus    = domainObject.SendStatus;
     entity.AlertOrCansel = int.Parse(domainObject.AlertOrCansel);
 }
        public AlertJson ToDomainObject(EfAlerts entity)
        {
            AlertJson _AlertJson = new AlertJson();

            _AlertJson.ID            = entity.ID.ToString();
            _AlertJson.Title         = entity.Title;
            _AlertJson.AlarmDate     = entity.AlarmDate.ToString();
            _AlertJson.AlarmTarikh   = entity.AlarmTarikh;
            _AlertJson.SaatErsal     = entity.SaatErsal;
            _AlertJson.AlarmType     = entity.AlarmType.ToString();
            _AlertJson.MeetingId     = entity.MeetingId.ToString();
            _AlertJson.IsSent        = entity.IsSent.ToString();
            _AlertJson.UserID        = new UserTranslator().ToDomainObject(entity.User).ID;
            _AlertJson.User          = new UserTranslator().ToDomainObject(entity.User);
            _AlertJson.SendStatus    = entity.SendStatus.ToString();
            _AlertJson.AlertOrCansel = entity.AlertOrCansel.ToString();
            _AlertJson.FullName      = new UserTranslator().ToDomainObject(entity.User).FullName;


            return(_AlertJson);
        }