public CustomerInsurance UpdateValues(string document, CustomerInsurance add) { add.document = document; add.start = DateTime.Now; return(add); }
public bool AssignInsurance(int customerId, int insuranceId) { IList <CustomerInsurance> existingItems = context.CustomerInsurances .Where(ci => ci.CustomerID == customerId) .Where(ci => ci.InsuranceID == insuranceId).ToList(); if (existingItems.Count == 0) { Customer customer = context.Customers.Where(c => (c.Id == customerId)).Include(c => (c.CustomerInsurances)).FirstOrDefault(); Insurance insurance = context.Insurances.Where(i => (i.Id == insuranceId)).FirstOrDefault(); if (customer != null && insurance != null) { var customerInsurance = new CustomerInsurance() { Customer = customer, Insurance = insurance }; customer.CustomerInsurances.Add(customerInsurance); context.SaveChanges(); return(true); } } return(false); }
public bool AssignInsurance(int customerId, int insuranceId) { IList <CustomerInsurance> existingItems = _customerInsurancesList .Where(ci => ci.CustomerID == customerId) .Where(ci => ci.InsuranceID == insuranceId).ToList(); if (existingItems.Count == 0) { Customer customer = _customersList.FirstOrDefault(c => (c.Id == customerId)); Insurance insurance = _insurancesList.FirstOrDefault(i => (i.Id == insuranceId)); if (customer != null || insurance != null) { var customerInsurance = new CustomerInsurance() { Customer = customer, Insurance = insurance, }; customer.CustomerInsurances.Add(customerInsurance); return(true); } } return(false); }
public async Task <ExternalResponse> CreateCustomerInsurance(CustomerInsurance customerInsurance) { return(new ExternalResponse { IsSuccessStatusCode = true, StatusCode = 201, Body = "" }); }
public bool RemoveInsurance(int customerId, int insuranceId) { CustomerInsurance customerInsurance = _customerInsurancesList .Where(ci => ci.CustomerID == customerId) .Where(ci => ci.InsuranceID == insuranceId).FirstOrDefault(); if (customerInsurance != null) { _customerInsurancesList.Remove(customerInsurance); return(true); } return(false); }
public bool RemoveInsurance(int customerId, int insuranceId) { CustomerInsurance customerInsurance = context.CustomerInsurances .Where(ci => ci.CustomerID == customerId) .Where(ci => ci.InsuranceID == insuranceId).FirstOrDefault(); if (customerInsurance != null) { context.CustomerInsurances.Remove(customerInsurance); context.SaveChanges(); return(true); } return(false); }
private CustomerInsuranceViewModel DomainToViewModel(CustomerInsurance domain) { CustomerInsuranceViewModel model = new CustomerInsuranceViewModel(); model.insurance.id = domain.Insurance.Id; model.insurance.name = domain.Insurance.Name; model.insurance.description = domain.Insurance.Description; model.insurance.coverageTime = domain.Insurance.CoverageTime; model.insurance.covering = domain.Insurance.Covering; model.insurance.riskLevel = domain.Insurance.RiskLevel; model.insurance.validFrom = domain.Insurance.ValidFrom; model.customerID = domain.CustomerID; model.insuranceID = domain.InsuranceID; return(model); }
public Task <ExternalResponse> CreateCustomerInsurance(CustomerInsurance customerInsurance) { InsuranceRepository.InsertCustomerInsurance(customerInsurance); InsuranceRepository.Save(); Task <ExternalResponse> task = new Task <ExternalResponse>(() => { return(new ExternalResponse { IsSuccessStatusCode = true, StatusCode = 201, Body = "" }); }); task.Start(); return(task); }
public List <CustomerInsurance> GetCustomerInsurance(int CustomerId)// { var lst = new List <CustomerInsurance>(); CustomerInsurance customerInsurance = null; using (var conn = new SqlConnection(PrescienceRxConnectionString)) { conn.Open(); using (var cmd = new SqlCommand(GetCustomerInsuranceByIDSp, conn)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add("@CustomerId", SqlDbType.Int); cmd.Parameters["@CustomerId"].Value = CustomerId; using (var myReader = cmd.ExecuteReader()) { try { if (myReader.HasRows) { while (myReader.Read()) { customerInsurance = new CustomerInsurance(myReader); lst.Add(customerInsurance); } } } catch (Exception ex) { // TODO Logg Error here } } } } return(lst); }
public bool UpdateCustomerInsurance(CustomerInsurance customerInsurance)// { using (var conn = new SqlConnection(PrescienceRxConnectionString)) { conn.Open(); using (var cmd = new SqlCommand(UpdateCustomerInsuranceSp, conn)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add("@CustomerId", SqlDbType.Int).Value = customerInsurance.CustomerId; cmd.Parameters.Add("@EffectiveDate", SqlDbType.DateTime).Value = customerInsurance.EffectiveDate; cmd.Parameters.Add("@FirstName", SqlDbType.DateTime).Value = customerInsurance.EndDate; cmd.Parameters.Add("@PcpName", SqlDbType.VarChar).Value = customerInsurance.PcpName; cmd.Parameters.Add("@CustomerInsuranceNumber", SqlDbType.VarChar).Value = customerInsurance.CustomerInsuranceNumber; cmd.Parameters.Add("@InsuranceType", SqlDbType.VarChar).Value = customerInsurance.InsuranceType; cmd.Parameters.Add("@CreatedBy", SqlDbType.Int).Value = customerInsurance.CreatedBy; cmd.Parameters.Add("@CreatedDate", SqlDbType.DateTime).Value = DateTime.UtcNow; return(Convert.ToBoolean(cmd.ExecuteScalar())); } } }
public bool PutUpdateCustomerInsurance([FromBody] CustomerInsurance customerInsurance) { return(repository.UpdateCustomerInsurance(customerInsurance)); }
public bool PostAddCustomerInsurance([FromBody] CustomerInsurance customerInsurance) { return(repository.AddCustomerInsurance(customerInsurance)); }
public Task <ExternalResponse> GetCustomerInsurances(CustomerInsurance customerInsurance) { throw new NotImplementedException(); }
public ActionResult <Insurance> Post([FromBody] CustomerInsurance value) { return(Ok(this.repository.Insert(value))); }