コード例 #1
0
 public InfectionDTO Map(Infection infectionEntity)
 {
     if (infectionEntity == null) return null;
     var infectionDto = Mapper.Map<Infection, InfectionDTO>(infectionEntity);
     return infectionDto;
 }
コード例 #2
0
        public async Task<ResponseBool> InfectionSaveAsync(Infection infection)
        {
            ResponseBool _response = new ResponseBool { Success = false, ErrorInfo = "" };
            var dto = _masterDataToDTOMapping.Map(infection);
            if (dto == null)
                return _response;

            string url = string.Format("api/pushmasterdata/infection/save");
            var httpClient = setupHttpClient();
            httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            try
            {
                var response = await httpClient.PostAsJsonAsync(url, dto);
                _response = await response.Content.ReadAsAsync<ResponseBool>();

            }
            catch (Exception ex)
            {
                _response.ErrorInfo = "Failed to save infection DTO.\n" + ex.Message;
                _log.Error("Failed to save infection DTO", ex);
            }
            return _response;
        }
コード例 #3
0
        private async void Save()
        {
            using (var c = NestedContainer)
            {
                Infection infection = Using<IInfectionRepository>(c).GetById(Id);;
            
                if (infection==null)
                {
                    infection = new Infection(Id);
                }
                infection.Code = Code;
                infection.Name = Name;
                infection.InfectionType = SelectedInfectionType;
                infection.Description = Description;
                infection._Status = EntityStatus.Active;
                infection._DateCreated = DateTime.Now;
                var response =await Using<IDistributorServiceProxy>(c).InfectionSaveAsync(infection);

                
                if(response.Success)
                {
                    MessageBox.Show("Infection Successfully Added", "Agrimangr: Manage Infection ",
                                   MessageBoxButton.OK, MessageBoxImage.Information);
                    SendNavigationRequestMessage(new Uri("/Views/Admin/FarmActivities/Infections/ListInfection.xaml", UriKind.Relative));
                }
                else
                {

                    MessageBox.Show(response.ErrorInfo, "Agrimangr: Manage Infection ",
                                   MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }

        }
コード例 #4
0
 protected Guid AddInfection(string name, string code, string description, InfectionType type)
 {
     var  infection = new Infection(Guid.NewGuid())
     {
         Name = name,
        Code = code,
        InfectionType = type,
        Description = description
     };
     infection._SetStatus(EntityStatus.Active);
     return _InfectionRepository.Save(infection);
 }
コード例 #5
0
 private void AssertInfection(Infection infection, Infection savedInfection)
 {
     Assert.AreEqual(infection.Code, savedInfection.Code);
     Assert.AreEqual(infection.Name, savedInfection.Name);
     Assert.AreEqual(infection.Code, savedInfection.Code);
     Assert.AreEqual(infection.Description, savedInfection.Description);
     Assert.AreEqual(infection.InfectionType, savedInfection.InfectionType);
     Assert.AreEqual(infection._Status, savedInfection._Status);
 }