コード例 #1
0
        public async Task <MedicalProfileResponse> UpdateAsync(int id, MedicalProfile medicalprofile)
        {
            var existingmedicalprofile = await _medicalprofileRepository.FindByIdAsync(id);

            if (existingmedicalprofile == null)
            {
                return(new MedicalProfileResponse(" medicalprofile not found"));
            }

            existingmedicalprofile.Name        = medicalprofile.Name;
            existingmedicalprofile.Weight      = medicalprofile.Weight;
            existingmedicalprofile.Lenght      = medicalprofile.Lenght;
            existingmedicalprofile.Eyes        = medicalprofile.Eyes;
            existingmedicalprofile.Breed       = medicalprofile.Breed;
            existingmedicalprofile.Sex         = medicalprofile.Sex;
            existingmedicalprofile.Color       = medicalprofile.Color;
            existingmedicalprofile.Description = medicalprofile.Description;
            existingmedicalprofile.Photo       = medicalprofile.Photo;
            existingmedicalprofile.Age         = medicalprofile.Age;

            try
            {
                _medicalprofileRepository.Update(existingmedicalprofile);
                await _unitOfWork.CompleteAsync();

                return(new MedicalProfileResponse(existingmedicalprofile));
            }
            catch (Exception ex)
            {
                return(new MedicalProfileResponse($"An error ocurred while updating the medicalprofile: {ex.Message}"));
            }
        }
コード例 #2
0
 public MedicalProfile GetMedicalProfileById(long id)
 {
     try
     {
         MedicalProfile result = _ctx.MedicalProfiles.Find(id);
         return(result);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
コード例 #3
0
 public long CreateMedicalProfile(MedicalProfile entry)
 {
     try
     {
         _ctx.MedicalProfiles.Add(entry);
         _ctx.SaveChanges();
         return(entry.Id);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
コード例 #4
0
        public long UpdateMedicalProfile(MedicalProfile entity)
        {
            try
            {
                entity.DateUpdated       = DateTime.UtcNow;
                _ctx.Entry(entity).State = System.Data.Entity.EntityState.Modified;
                _ctx.SaveChanges();

                return(entity.Id);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #5
0
        public async Task <MedicalProfileResponse> SaveAsync(MedicalProfile medicalprofile)
        {
            try
            {
                await _medicalprofileRepository.AddAsyn(medicalprofile);

                await _unitOfWork.CompleteAsync();

                return(new MedicalProfileResponse(medicalprofile));
            }
            catch (Exception ex)
            {
                return(new MedicalProfileResponse($"An error ocurred while saving the medicalprofile: {ex.Message}"));
            }
        }
コード例 #6
0
        public long DeleteMedicalProfile(long id)
        {
            try
            {
                MedicalProfile entry = _ctx.MedicalProfiles.Find(id);
                entry.DateUpdated       = DateTime.UtcNow;
                _ctx.Entry(entry).State = System.Data.Entity.EntityState.Modified;
                _ctx.SaveChanges();

                return(id);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #7
0
        public GetMedicalProfileOutput GetMedicalProfile(GetMedicalProfileInput input)
        {
            GetMedicalProfileOutput outputToReturn = new GetMedicalProfileOutput();

            try
            {
                MedicalProfile medicalProfile = _medicalProfileRepository.GetMedicalProfileById(input.Id);

                if (medicalProfile != null)
                {
                    outputToReturn.MedicalProfile = new MedicalProfileModel();
                    MedicalProfileModel model = new MedicalProfileModel();
                    model.Id                    = medicalProfile.Id;
                    model.UserId                = medicalProfile.UserID;
                    model.FirstName             = medicalProfile.FirstName;
                    model.LastName              = medicalProfile.LastName;
                    model.GenderSD              = medicalProfile.GenderSD;
                    model.MaritalStatusSD       = medicalProfile.MaritalStatusSD;
                    model.Age                   = medicalProfile.Age;
                    model.BloodType             = medicalProfile.BloodTypeSD;
                    model.WeightSD              = medicalProfile.WeightSD;
                    model.HeightSD              = medicalProfile.HeightSD;
                    model.Occupation            = medicalProfile.Occupation;
                    model.HaveInsurance         = medicalProfile.HaveInsurance;
                    model.HaveNSSF              = medicalProfile.HaveNSSF;
                    model.Smoker                = medicalProfile.Smoker;
                    model.HaveChildren          = medicalProfile.HaveChildren;
                    model.CaffeineDrinker       = medicalProfile.CaffeineDrinker;
                    model.CaffeinePerDay        = medicalProfile.CaffeinePerDay;
                    model.TakeMedication        = medicalProfile.TakeMedication;
                    model.HavePreviousSurgeries = medicalProfile.HavePreviousSurgeries;
                    model.HaveMedicationAllergy = medicalProfile.HaveMedicationAllergy;
                    model.HaveOtherAllergy      = medicalProfile.HaveOtherAllergy;
                    model.FamilyMedicalHistory  = medicalProfile.FamilyMedicalHistory;
                }

                return(outputToReturn);
            }
            catch (Exception ex)
            {
                WriteLogFile.Append("GetMedicalProfile : ");
                WriteLogFile.Append(ex.Message);
                WriteLogFile.Append(ex.StackTrace);
                return(null);
            }
        }
コード例 #8
0
        // add new medical record by current user
        public CreateMedicalProfileOutput CreateMedicalProfile(CreateMedicalProfileInput input)
        {
            CreateMedicalProfileOutput outputToReturn = new CreateMedicalProfileOutput();

            try
            {
                MedicalProfile medicalProfile = new MedicalProfile();
                medicalProfile.UserID                = _apiSession.CurrentUserID;
                medicalProfile.FirstName             = input.FirstName;
                medicalProfile.LastName              = input.LastName;
                medicalProfile.GenderSD              = input.GenderSD;
                medicalProfile.MaritalStatusSD       = input.MaritalStatusSD;
                medicalProfile.Age                   = input.Age;
                medicalProfile.BloodTypeSD           = input.BloodType;
                medicalProfile.WeightSD              = input.WeightSD;
                medicalProfile.HeightSD              = input.HeightSD;
                medicalProfile.Occupation            = input.Occupation;
                medicalProfile.HaveInsurance         = input.HaveInsurance;
                medicalProfile.HaveNSSF              = input.HaveNSSF;
                medicalProfile.Smoker                = input.Smoker;
                medicalProfile.HaveChildren          = input.HaveChildren;
                medicalProfile.CaffeineDrinker       = input.CaffeineDrinker;
                medicalProfile.CaffeinePerDay        = input.CaffeinePerDay;
                medicalProfile.TakeMedication        = input.TakeMedication;
                medicalProfile.HavePreviousSurgeries = input.HavePreviousSurgeries;
                medicalProfile.HaveMedicationAllergy = input.HaveMedicationAllergy;
                medicalProfile.HaveOtherAllergy      = input.HaveOtherAllergy;
                medicalProfile.FamilyMedicalHistory  = input.FamilyMedicalHistory;
                medicalProfile.CreateUserID          = _apiSession.CurrentUserID;
                medicalProfile.DateCreated           = DateTime.UtcNow;

                long Id = _medicalProfileRepository.CreateMedicalProfile(medicalProfile);

                outputToReturn.Id = Id;
                outputToReturn.ReturnStatus.OK();
                return(outputToReturn);
            }
            catch (Exception ex)
            {
                WriteLogFile.Append("CreateMedicalProfile : ");
                WriteLogFile.Append(ex.Message);
                WriteLogFile.Append(ex.StackTrace);
                return(null);
            }
        }
コード例 #9
0
 public void Update(MedicalProfile medicalprofile)
 {
     _context.Update(medicalprofile);
 }
コード例 #10
0
        public void Remove(MedicalProfile medicalprofile)
        {
            //var pet =  _context.Pets.FindAsync(petId);

            _context.MedicalProfiles.Remove(medicalprofile);
        }
コード例 #11
0
 public async Task AddAsyn(MedicalProfile medicalprofile)
 {
     await _context.MedicalProfiles.AddAsync(medicalprofile);
 }
コード例 #12
0
 public MedicalProfileResponse(MedicalProfile medicalprofile) : this(true, string.Empty, medicalprofile)
 {
 }
コード例 #13
0
 public MedicalProfileResponse(bool success, string message, MedicalProfile medicalprofile) : base(success, message)
 {
     MedicalProfile = medicalprofile;
 }
コード例 #14
0
        public async Task <MedicalProfileResponse> SaveByPetIdAsync(int providerId, int customerId, int petId, MedicalProfile medicalprofile)
        {
            /* var customer = _customerRepository.FindByIdAsync(customerId);
             * if ( customer==null )
             * {
             *   return new MedicalProfileResponse("Not Found customer");
             * }
             */


            try
            {
                var petDB      = _petRepository.FindByIdAsync(petId);
                var providerDB = _providerRepository.FindByIdAsync(providerId);
                medicalprofile.Pet        = petDB.Result;
                medicalprofile.PetId      = petId;
                medicalprofile.Provider   = providerDB.Result;
                medicalprofile.ProviderId = providerId;

                await _medicalprofileRepository.AddAsyn(medicalprofile);

                await _unitOfWork.CompleteAsync();

                return(new MedicalProfileResponse(medicalprofile));
            }
            catch (Exception ex)
            {
                return(new MedicalProfileResponse($"An error ocurred while saving th medicalprofile: {ex.Message}"));
            }
        }