Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            InsuranceQuery insuranceQuery = db.InsuranceQueries.Find(id);

            db.InsuranceQueries.Remove(insuranceQuery);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        /// <summary>
        /// Generic query expression for Insurance service
        /// </summary>
        /// <param name="insuranceQuery">insuranceQuery having query on insurance</param>
        /// <returns>Func delegate to return to the Entity framework of type Insurance,bool</returns>
        public static Func <Insurance, bool> Insurance(InsuranceQuery insuranceQuery)
        {
            var ifInsuranceQueryIdIsZero = !insuranceQuery.Id.Equals(CommonInteger.OptionalIntegerParam);

            return(new Func <Insurance, bool>(m => (ifInsuranceQueryIdIsZero ? m.Id.Equals(insuranceQuery.Id) : true) &&
                                              (!string.IsNullOrWhiteSpace(insuranceQuery.Name) ? m.Name.IndexOf(insuranceQuery.Name, StringComparison.OrdinalIgnoreCase) >= 0 : true) &&
                                              (!string.IsNullOrWhiteSpace(insuranceQuery.PhoneNumber) ? m.Phone.Equals(insuranceQuery.PhoneNumber) : true) &&
                                              (!string.IsNullOrWhiteSpace(insuranceQuery.PubId) ? m.PublicId.Equals(insuranceQuery.PubId) : true)));
        }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "ID,firstName,lastName,email,birthdate,car_year,car_make,car_model,tickets,dui,coverage_full,calculated_rate")] InsuranceQuery insuranceQuery)
 {
     if (ModelState.IsValid)
     {
         db.Entry(insuranceQuery).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(insuranceQuery));
 }
Esempio n. 4
0
        // GET: InsuranceQueries/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            InsuranceQuery insuranceQuery = db.InsuranceQueries.Find(id);

            if (insuranceQuery == null)
            {
                return(HttpNotFound());
            }
            return(View(insuranceQuery));
        }
 /// <summary>
 /// Method to get insurance from database based on user query.
 /// </summary>
 /// <param name="insuranceQuery">insuranceQuery contains query parameters to get insurances.</param>
 /// <returns>ResponseModel containing list of InsuranceDto.</returns>
 public ResponseModel Get(InsuranceQuery insuranceQuery)
 {
     using (var unitOfWork = new UnitOfWork())
     {
         //Creating a parameter less query model if it is null from request
         if (insuranceQuery == null)
         {
             insuranceQuery = new InsuranceQuery(id: CommonString.OptionalStringParamInteger, name: CommonString.OptionalStringParam, phoneNumber: CommonString.OptionalStringParam, pubId: CommonString.OptionalStringParam);
         }
         insuranceQuery.SetTypedVariables();
         var result = unitOfWork.Insurances.FindAll(QueryExpressions.Insurance(insuranceQuery));
         result = result.OrderByDescending(m => m.Id).ToList();
         return(ReturnStatements.SuccessResponse(CollectionConversions.ListInsurance(result)));
     }
 }
        public HttpResponseMessage Get([FromUri] InsuranceQuery insuranceQuery)
        {
            var result = _services.Get(insuranceQuery);

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }