コード例 #1
0
 public PetLastAlertDetailViewModel PetLastAlertToViewModel(PetLostAlert data)
 {
     return(new PetLastAlertDetailViewModel
     {
         AlertCode = data.AlertCode.ToString(),
         PetId = data.PetId,
         PetCode = data.PetCode?.ToString(),
         PetName = HttpUtility.HtmlDecode(data.PetName),
         PetProfileImageUrl = data.PetProfileImageUrl,
         Latitude = data.Latitude,
         Longitude = data.Longitude,
         LostDateTime = data.LostDateTime.ToString("dd / MMM / yyyy hh:mm:ss tt"),
         Description = HttpUtility.HtmlDecode(data.Description),
         LostComment = HttpUtility.HtmlDecode(data.LostComment)
     });
 }
コード例 #2
0
        private List <PetLostAlert> FormatAlertResults(List <Tuple <PetAlertTableModel, PetTableModel, OwnerTableModel, PetImageTableModel> > lostResults)
        {
            var alerts = new List <PetLostAlert>();

            PetLostAlert alert;

            foreach (var item in lostResults)
            {
                alert = new PetLostAlert
                {
                    AlertCode    = item.Item1.Code,
                    Type         = item.Item1.AlertType,
                    Latitude     = item.Item1.Latitude,
                    Longitude    = item.Item1.Longitude,
                    LostDateTime = item.Item1.CreatedOn,
                    LostComment  = item.Item1.Comment
                };

                if (item.Item2.Id != 0)
                {
                    alert.PetId              = item.Item2.Id;
                    alert.PetCode            = item.Item2.Code;
                    alert.PetName            = item.Item2.Name;
                    alert.Description        = item.Item2.Description;
                    alert.PetProfileImageUrl = item.Item4.ImageUrl;
                }
                else
                {
                    alert.PetName = GeneralHelper.GetAnonymousTitle(item.Item1.AlertType);
                }

                alerts.Add(alert);
            }

            return(alerts);
        }