示例#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);
        }
示例#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);
        }
示例#3
0
 public void Delete([FromBody] RepairBillModel value)
 {
     new RepairBillService().Remove(value);
 }
示例#4
0
 public void Put([FromBody] RepairBillModel value)
 {
     new RepairBillService().AddOrUpdate(value);
 }
示例#5
0
        // PUT: api/RepairBill/5
        public void Put(int id, [FromBody] RepairBillModel value)
        {
            var service = new RepairBillService();

            service.AddOrEditRepairBill(value);
        }