Ejemplo n.º 1
0
 /// <summary>
 /// Maps a PositiveCase to a PositiveCaseResource.
 /// </summary>
 /// <param name="positiveCase">The positive case.</param>
 /// <returns>A positive case</returns>
 public static PositiveCaseResource ToPositiveCaseResource(this PositiveCase positiveCase)
 {
     return(new PositiveCaseResource()
     {
         Id = positiveCase.Id,
         AllUsersNotified = positiveCase.AllUsersNotified,
         VisitDate = positiveCase.VisitDate,
         VisitorId = positiveCase.Visitor.Id,
         VisitorName = positiveCase.Visitor.Name
     });
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Maps a PositiveCase to PositiveCaseModel.
 /// </summary>
 /// <param name="positiveCase">The positive case.</param>
 /// <returns>A positive case model</returns>
 public static PositiveCaseModel ToPositiveCaseModel(this PositiveCase positiveCase)
 {
     return(new PositiveCaseModel()
     {
         Id = positiveCase.Id,
         CreatedBy = positiveCase.CreatedBy,
         CreatedOn = positiveCase.CreatedOn,
         UpdatedBy = positiveCase.UpdatedBy,
         UpdatedOn = positiveCase.UpdatedOn,
         Visitor = positiveCase.Visitor?.ToVisitorModel(),
         AllUsersNotified = positiveCase.AllUsersNotified,
         VisitDate = positiveCase.VisitDate
     });
 }
        public IActionResult Update(VisitorNotificationResource visitorNotification)
        {
            try
            {
                VisitorNotificationManager visitorNotificationMng = new VisitorNotificationManager();
                var visitorNotificationDb = visitorNotificationMng.GetRecordById(visitorNotification.Id);
                if (visitorNotificationDb == null)
                {
                    return(BadRequest("Invalid visitor notification id!"));
                }

                visitorNotificationDb.SentDate = visitorNotification.SentDate;

                if (visitorNotificationDb.Visitor.Id != visitorNotification.VisitorId)
                {
                    VisitorManager visitorMng = new VisitorManager();
                    Visitor        visitor    = visitorMng.GetRecordById(visitorNotification.VisitorId);
                    if (visitor == null)
                    {
                        return(BadRequest("Invalid visitor id!"));
                    }
                    visitorNotificationDb.Visitor = visitor;
                }

                if (visitorNotificationDb.PositiveCase.Id != visitorNotification.PositiveCaseId)
                {
                    PositiveCaseManager positiveCaseMng = new PositiveCaseManager();
                    PositiveCase        positiveCase    = positiveCaseMng.GetRecordById(visitorNotification.PositiveCaseId);
                    if (positiveCase == null)
                    {
                        return(BadRequest("Invalid positive case id!"));
                    }
                    visitorNotificationDb.PositiveCase = positiveCase;
                }

                visitorNotificationMng.Update(visitorNotificationDb);
                return(Ok());
            }
            catch (EntityValidationException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch
            {
                return(Problem());
            }
        }