public TreatmentDailyUpdateDTO GetDailyUpdateByDate(int tduid)
        {
            TreatmentDailyUpdateDTO response = new TreatmentDailyUpdateDTO();

            response = DomainDTOMapper.ToTreatmentDailyUpdateDTO(_treatmentDailyUpdateRepository.FirstOrDefault(x => x.Tduid == tduid));

            response.TreatmentImageURLs = _treatmentDailyUpdatePhotosRepository.All.Where(p => p.Tduid == tduid && p.CustomerId == response.CustomerId).Select(p => p.FileName).ToList();

            return(response);
        }
        public bool SaveTreatmentDailyUpdate(TreatmentDailyUpdateDTO dailyUpdate)
        {
            try
            {
                _treatmentDailyUpdateRepository.Add(DomainDTOMapper.ToTreatmentDailyUpdateDomain(dailyUpdate));
                _treatmentDailyUpdateRepository.SaveChanges();

                var lastDailyUpdate = _treatmentDailyUpdateRepository.All.OrderByDescending(x => x.Date).FirstOrDefault();

                if (dailyUpdate?.TreatmentImageURLs != null)
                {
                    foreach (var url in dailyUpdate.TreatmentImageURLs)
                    {
                        var imageName = string.Format(@"{0}", Guid.NewGuid());

                        ImageConverter.SaveImage(url, imageName);

                        Tbl_TreatmentDailyUpdatePhotos model = new Tbl_TreatmentDailyUpdatePhotos()
                        {
                            Tduid      = lastDailyUpdate.Tduid,
                            CustomerId = lastDailyUpdate.CustomerId,
                            FileName   = imageName
                        };

                        _treatmentDailyUpdatePhotosRepository.Add(model);
                        _treatmentDailyUpdatePhotosRepository.SaveChanges();
                    }
                }


                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
 public void TempError([FromBody] TreatmentDailyUpdateDTO dailyUpdates)
 {
     var er = dailyUpdates.CustomerId;
 }
Ejemplo n.º 4
0
 public IActionResult Post([FromBody] TreatmentDailyUpdateDTO dailyUpdates)
 {
     return(Ok(_treatmentDailyUpdateService.SaveTreatmentDailyUpdate(dailyUpdates)));
 }
Ejemplo n.º 5
0
 public static Tbl_TreatmentDailyUpdate ToTreatmentDailyUpdateDomain(TreatmentDailyUpdateDTO dailyUpdateDto)
 {
     return(AutoMapper.Mapper.Map <TreatmentDailyUpdateDTO, Tbl_TreatmentDailyUpdate>(dailyUpdateDto));
 }