예제 #1
0
        public ActionResult Create([Bind(Include = "ID,FirstName,LastName,EmailAddress,DateOfBirth,CarYear,CarMake,CarModel,DUI,SpeedingTickets,Coverage")] Applicant applicant)
        {
            if (ModelState.IsValid)
            {
                db.Applicants.Add(applicant);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(applicant));
        }
        public ActionResult Create([Bind(Include = "ID,Name,Percentage,Period")] Coverage coverage)
        {
            if (ModelState.IsValid)
            {
                db.Coverages.Add(coverage);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(coverage));
        }
        public ActionResult Create([Bind(Include = "ID,Name")] Client client)
        {
            if (ModelState.IsValid)
            {
                db.Clients.Add(client);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(client));
        }
        public string Index()
        {
            var insurance = new Insurance("Seguro blah", 2, "1234334", "Alberto Noronha");

            _context.insurances.Add(insurance);
            _context.SaveChanges();

            int insurance_id = _context.insurances.Where(i => i.Id > 0).First().Id;

            var life = new HouseInsurance("Rua abc", 5, "RS", "Brazil", insurance_id);

            _context.house_insurances.Add(life);
            _context.SaveChanges();

            return("Huehuebr lIFE " + _context.house_insurances.Count() + " --- iNSU: " + _context.insurances.Count());
        }
예제 #5
0
        public ActionResult Order(Order o)
        {
            Order order = insuranceContext.Orders.Add(o);

            insuranceContext.SaveChanges();

            return(View("OrderComplete", order));
        }
예제 #6
0
        public bool DelClientById(int id)
        {
            bool accion = true;

            Client client = _context.Client.FirstOrDefault(x => x.Id == id);

            if (client == null)
            {
                accion = false;
                return(accion);
            }

            _context.Client.Remove(client);
            _context.SaveChanges();

            return(accion);
        }
예제 #7
0
        public bool DelInsuranceById(int id)
        {
            bool result = true;

            Insurance insurance = _context.Insurance.FirstOrDefault(x => x.Id == id);

            if (insurance == null)
            {
                result = false;
                return(result);
            }

            _context.Insurance.Remove(insurance);
            _context.SaveChanges();

            return(result);
        }
        public ActionResult Create(PolicyViewModel policyViewModel)
        {
            if (ModelState.IsValid)
            {
                if (!ValidateCoverages(policyViewModel))
                {
                    return(View(policyViewModel));
                }

                if (!ValidateHighRiskCoverages(policyViewModel))
                {
                    return(View(policyViewModel));
                }

                var policyToAdd = db.Policies.Include(i => i.Coverages).First();

                if (TryUpdateModel(policyToAdd, "Policy", new string[] { "ID", "Name", "Description", "ValidityStart", "Price", "RiskType" }))
                {
                    var selectedCoverages = new HashSet <int>(policyViewModel.SelectedCoverages);

                    foreach (Coverage coverage in db.Coverages)
                    {
                        if (!selectedCoverages.Contains(coverage.ID))
                        {
                            policyToAdd.Coverages.Remove(coverage);
                        }
                        else
                        {
                            policyToAdd.Coverages.Add((coverage));
                        }
                    }
                }

                db.Policies.Add(policyToAdd);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            LoadCoverages();

            ViewBag.ClientID = new SelectList(db.Clients, "ID", "Name");

            return(View(policyViewModel));
        }
예제 #9
0
        public void Delete(Content content)
        {
            using var context = new InsuranceContext();
            var entity = context.Content.Remove(content);

            entity.State = EntityState.Deleted;

            context.SaveChanges();
        }
예제 #10
0
        public void Add(Content content)
        {
            using var context = new InsuranceContext();
            var entity = context.Content.Add(content);

            entity.State = EntityState.Added;

            context.SaveChanges();
        }
예제 #11
0
        public int Delete(int id)
        {
            int rec = 0;

            try
            {
                var dataToReturn = _TdbSet.Find(id);
                if (dataToReturn != null)
                {
                    _TdbSet.Remove(dataToReturn);
                    rec = _tcontext.SaveChanges();
                }
                else
                {
                    throw new Exception("Record not found while deleting record");
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error while deleting record", ex);
            }
            return(rec);
        }
예제 #12
0
 public void Add(Insurance insurance)
 {
     context.Insurances.Add(insurance);
     context.SaveChanges();
 }
예제 #13
0
 /// <summary>
 /// Create a new policy
 /// </summary>
 /// <param name="policy">New policy</param>
 public void Post(Policy policy)
 {
     policy = verifyRisk(policy);
     db.Policies.Add(policy);
     db.SaveChanges();
 }
예제 #14
0
 /// <summary>
 /// Create a new client
 /// </summary>
 /// <param name="client">New client</param>
 public void Post(Client client)
 {
     db.Clients.Add(client);
     db.SaveChanges();
 }
 public void AddItem(Item item)
 {
     _context.Items.Add(item);
     _context.SaveChanges();
 }
예제 #16
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new InsuranceContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <InsuranceContext> >()))
            {
                if (context.Agent.Any() || context.Case.Any() || context.Policy.Any() || context.CascoPolicy.Any() || context.TravelPolicy.Any() || context.HealthPolicy.Any() || context.User.Any())
                {
                    return;
                }

                context.Agent.AddRange(
                    new Agent { /* Id = 1 */
                    AgentNumber = "00001", FirstName = "Венко", LastName = "Филипче", PolicyCount = 1, BirthDate = DateTime.Parse("1990-1-1"), HireDate = DateTime.Parse("2020-1-1"), ProfilePicture = ""
                },
                    new Agent { /* Id = 2 */
                    AgentNumber = "00002", FirstName = "Катица", LastName = "Јанева", PolicyCount = 2, BirthDate = DateTime.Parse("1990-1-2"), HireDate = DateTime.Parse("2020-1-2"), ProfilePicture = ""
                }
                    );
                context.SaveChanges();

                context.User.AddRange(
                    new User { /* Id = 1 */
                    FirstName = "Владимир", LastName = "Крстиќ", EMBG = "0812998451234", BirthDate = DateTime.Parse("1998-12-8")
                },
                    new User { /* Id = 2 */
                    FirstName = "Ненад", LastName = "Човекот", EMBG = "1903998451234", BirthDate = DateTime.Parse("1998-3-19")
                }
                    );
                context.SaveChanges();

                context.Case.AddRange(
                    new Case
                {    /* Id = 1 */
                    CaseNumber   = "1",
                    Description  = "I made an accident, dude!",
                    AccidentDate = DateTime.Parse("2020-5-1"),
                    UserId       = 2
                },
                    new Case
                {    /* Id = 2 */
                    CaseNumber   = "2",
                    Description  = "I made an accident, dude!",
                    AccidentDate = DateTime.Parse("2020-5-2"),
                    UserId       = 1
                }
                    );
                context.SaveChanges();

                context.Policy.AddRange(
                    new Policy
                {     /* Id = 1 */
                    PolicyNumber = "A0001",
                    PolicyType   = PolicyType.CascoPolicy,
                    OwnerId      = 1,
                    AgentId      = 2,
                },
                    new Policy
                {     /* Id = 2 */
                    PolicyNumber = "A0002",
                    PolicyType   = PolicyType.TravelPolicy,
                    OwnerId      = 2,
                    AgentId      = 1,
                },
                    new Policy
                {     /* Id = 3 */
                    PolicyNumber = "A0003",
                    PolicyType   = PolicyType.HealthPolicy,
                    OwnerId      = 2,
                    AgentId      = 1,
                }
                    );
                context.SaveChanges();

                context.CascoPolicy.AddRange(
                    new CascoPolicy
                {
                    /*Id = 1*/
                    Chassis      = "CHA0000000001",
                    Registration = "AA1234BB",
                    Power        = 50,
                    Volume       = 1000,
                    Premium      = 200,
                    VehicleColor = "црвена",
                    AgreeDate    = DateTime.Parse("2020-2-1"),
                    PolicyId     = 1
                }
                    );
                context.SaveChanges();

                context.TravelPolicy.AddRange(
                    new TravelPolicy
                {
                    /*Id = 1*/
                    TypeTravel = "Classic",
                    DayCount   = 30,
                    Premium    = 100,
                    AgreeDate  = DateTime.Parse("2020-2-1"),
                    InsuredId  = 1,
                    PolicyId   = 2
                }
                    );
                context.SaveChanges();

                context.HealthPolicy.AddRange(
                    new HealthPolicy
                {
                    /*Id = 1*/
                    TypeHealth = "A",
                    Premium    = 100,
                    AgreeDate  = DateTime.Parse("2020-2-1"),
                    InsuredId  = 2,
                    PolicyId   = 3
                }
                    );
                context.SaveChanges();
            }
        }
예제 #17
0
 public void Add(Request request)
 {
     context.Requests.Add(request);
     context.SaveChanges();
 }
예제 #18
0
 public void Add(Insurance entity)
 {
     _insuranceContext.Insurances.Add(entity);
     _insuranceContext.SaveChanges();
 }