Exemplo n.º 1
0
        //REPAIRS BILLS
        public bool AddOrEditRepairBill(RepairBillModel newRepairBill)
        {
            if (newRepairBill.id_naprawy == null)
            {
                return(false);       //This repair bill is not connected to any repair - kinda useless.
            }
            try
            {
                using (var ctx = new DBProjectEntities())
                {
                    var repairBill = ctx.FakturyNapraw.Find(newRepairBill.id_faktury);
                    if (repairBill == null)  //DB did not find any record like provided one. Add it.
                    {
                        repairBill = ModelMapper.Mapper.Map <FakturyNapraw>(newRepairBill);
                        ctx.FakturyNapraw.Add(repairBill);
                    }
                    else//There's a record that contains the residence already - modify it.
                    {
                        repairBill.cena           = newRepairBill.cena;
                        repairBill.data_platnosci = newRepairBill.data_platnosci;
                        repairBill.id_naprawy     = newRepairBill.id_naprawy;
                        repairBill.numer_faktury  = newRepairBill.numer_faktury;
                        repairBill.id_faktury     = newRepairBill.id_faktury;
                    }
                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public RepairBillModel GetSingleRepairBillModel(int repairBillId)
        {
            var repairBill = new RepairBillModel();

            try
            {
                using (var ctx = new DBProjectEntities())
                {
                    var queryResult = ctx.FakturyNapraw.Find(repairBillId);

                    repairBill = ModelMapper.Mapper.Map <RepairBillModel>(queryResult);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(repairBill);
        }
Exemplo n.º 3
0
 public void Delete([FromBody] RepairBillModel value)
 {
     new RepairBillService().Remove(value);
 }
Exemplo n.º 4
0
 public void Put([FromBody] RepairBillModel value)
 {
     new RepairBillService().AddOrUpdate(value);
 }
Exemplo n.º 5
0
        // PUT: api/RepairBill/5
        public void Put(int id, [FromBody] RepairBillModel value)
        {
            var service = new RepairBillService();

            service.AddOrEditRepairBill(value);
        }