Ejemplo n.º 1
0
        public IActionResult CancelBooking([frombody] BookInstrument obj)
        {
            int id   = obj.Id;
            var data = rep2.CancelBooking(id);

            return(Ok());
        }
Ejemplo n.º 2
0
        public BookInstrument ApproveBooking(BookInstrument obj)
        {
            obj.Approval.ToLower();
            obj.Instrument = db.Instruments.Find(obj.Instrument.Id);
            obj.User       = db.Users.Find(obj.User.Id);
            obj.Project    = db.Projects.Find(obj.Project.Id);
            int id = obj.Instrument.Id;
            InstrumentCondition IC = db.InstrumentConditions.Where(a => a.Instrument.Id == id).FirstOrDefault();
            var olddata            = db.BookInstruments.Find(obj.Id);

            var temp = from book in db.BookInstruments.Where(a => a.Instrument.Id == obj.Instrument.Id)

                       select new BookInstrument
            {
                From     = book.From,
                To       = book.To,
                Approval = book.Approval
            };
            bool t1    = true;
            var  temp2 = temp.ToList();

            foreach (var item in temp2)
            {
                if ((obj.From >= item.From && obj.From <= item.To) || (obj.To >= item.From && obj.To <= item.To))
                {
                    if (item.Approval == "approved")
                    {
                        t1 = false;
                        break;
                    }
                }
            }
            if (t1 == true)
            {
                olddata.From = olddata.From;
                olddata.To   = olddata.To;
                olddata.ActualWorkingHours = olddata.ActualWorkingHours;
                olddata.Approval           = "approved";
                olddata.Notes         = olddata.Notes;
                olddata.AdditionalReq = olddata.AdditionalReq;
                olddata.Instrument    = obj.Instrument;
                olddata.User          = olddata.User;
                olddata.Project       = olddata.Project;
                //IC.Condition = false;
                db.SaveChanges();
                return(obj);
            }
            else
            {
                BookInstrument i = new BookInstrument();
                return(i);
            }
        }
Ejemplo n.º 3
0
        public IActionResult ApproveBooking([FromBody] BookInstrument obj)
        {
            var data = rep2.ApproveBooking(obj);

            if (data.Id != 0)
            {
                return(Ok());
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 4
0
        public ActionResult book([FromBody] BookInstrument obj)
        {
            BookInstrument b2 = new BookInstrument();

            b2.From = obj.From;
            b2.To   = obj.To;
            b2.ActualWorkingHours = obj.ActualWorkingHours;
            b2.Approval           = obj.Approval;
            b2.Notes         = obj.Notes;
            b2.AdditionalReq = obj.AdditionalReq;

            b2.Instrument = db.Instruments.Find(obj.Instrument.Id);

            b2.User    = db.Users.Find(obj.User.Id);
            b2.Project = db.Projects.Find(obj.Project.Id);


            rep.bookinstrumet(b2);

            return(Ok(b2));
        }
Ejemplo n.º 5
0
        public BookInstrument UpdateBooking(BookInstrument obj)
        {
            obj.Approval.ToLower();
            obj.Instrument = db.Instruments.Find(obj.Instrument.Id);
            obj.User       = db.Users.Find(obj.User.Id);
            obj.Project    = db.Projects.Find(obj.Project.Id);
            int id = obj.Instrument.Id;
            InstrumentCondition IC = db.InstrumentConditions.Where(a => a.Instrument.Id == id).FirstOrDefault();

            var olddata = db.BookInstruments.Find(obj.Id);

            olddata.From = obj.From;
            olddata.To   = obj.To;
            olddata.ActualWorkingHours = obj.ActualWorkingHours;
            olddata.Approval           = obj.Approval;
            olddata.Notes         = obj.Notes;
            olddata.AdditionalReq = obj.AdditionalReq;
            olddata.Instrument    = obj.Instrument;
            olddata.User          = olddata.User;
            olddata.Project       = olddata.Project;

            db.SaveChanges();
            return(obj);
        }
Ejemplo n.º 6
0
 public void bookinstrumet(BookInstrument obj)
 {
     obj.Approval.ToLower();
     db.BookInstruments.Add(obj);
     db.SaveChanges();
 }
Ejemplo n.º 7
0
        public IActionResult UpdateBooking([FromBody] BookInstrument obj)
        {
            var data = rep2.UpdateBooking(obj);

            return(Ok());
        }