コード例 #1
0
 public bool Update(oContractor entity)
 {
     try
     {
         if (entity.Address != null)
         {
             entity.Address.ModifiedAt = entity.ModifiedAt;
             entity.Address.ModifiedBy = entity.ModifiedBy;
             contractorContext.Entry(entity.Address).State = EntityState.Modified;
         }
         if (entity.BankAccount != null)
         {
             entity.BankAccount.ModifiedAt = entity.ModifiedAt;
             entity.BankAccount.ModifiedBy = entity.ModifiedBy;
             contractorContext.Entry(entity.BankAccount).State = EntityState.Modified;
         }
         contractorContext.Entry(entity).State = EntityState.Modified;
         return(true);
     }
     catch (Exception ex)
     {
         LogInfo.LogMessage(enumLogInfoType.Error, ex);
         return(false);
     }
 }
コード例 #2
0
 public bool Create(oContractor entity)
 {
     try
     {
         if (entity == null)
         {
             return(false);
         }
         if (entity.Id > 0)
         {
             Update(entity);
         }
         else
         {
             if (entity.Address != null)
             {
                 entity.Address.CreatedAt = entity.CreatedAt;
                 entity.Address.CreatedBy = entity.CreatedBy;
             }
             if (entity.BankAccount != null)
             {
                 entity.BankAccount.CreatedAt = entity.CreatedAt;
                 entity.BankAccount.CreatedBy = entity.CreatedBy;
             }
             contractorContext.Contractors.Add(entity);
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #3
0
        public void Create_Working_Good()
        {
            var cont = new oContractor()
            {
                NIP = "1231231233"
            };

            contractorRepository.Object.Create(cont);
            Assert.AreSame(cont.NIP, contractorList.Last().NIP);
        }
コード例 #4
0
        public HttpResponseMessage UpdateContractor(oContractor contractor)
        {
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, GetBaseUrl() + "/api/Contractor");

            string json = JsonConvert.SerializeObject(contractor);

            request.Content = new StringContent(json, Encoding.UTF8, "application/json");

            HttpClient          http     = new HttpClient();
            HttpResponseMessage response = httpClient.SendAsync(request).Result;

            return(response);
        }
コード例 #5
0
 public IActionResult Post([FromBody] oContractor value)
 {
     try
     {
         contractorRepository.Create(value);
         contractorRepository.Save();
         return(new OkResult());
     }
     catch (Exception ex)
     {
         LogInfo.LogMessage(enumLogInfoType.Error, ex);
         return(new BadRequestObjectResult(ex));
     }
 }
コード例 #6
0
 public IActionResult Delete([FromBody] oContractor value)
 {
     try
     {
         if (value == null)
         {
             return(new BadRequestObjectResult(value));
         }
         contractorRepository.Delete(value.Id);
         contractorRepository.Save();
         return(new OkResult());
     }
     catch (Exception ex)
     {
         LogInfo.LogMessage(enumLogInfoType.Error, ex);
         return(new BadRequestObjectResult(ex));
     }
 }