Ejemplo n.º 1
0
        public async Task <IActionResult> CreateFacility(tbFacility model)
        {
            if (ModelState.IsValid)
            {
                await _db.Facilities.AddAsync(model);

                await _db.SaveChangesAsync();

                return(Ok(model));
            }
            return(BadRequest());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> EditFacility(string id, tbFacility model)
        {
            if (id == null)
            {
                return(BadRequest(" ID cannot null!"));
            }
            var fac = await _db.Facilities.FindAsync(id);

            if (fac != null)
            {
                fac.FacName  = model.FacName;
                fac.isActive = model.isActive;
                _db.Update(fac);
                await _db.SaveChangesAsync();

                return(Ok("Edit Success!"));
            }
            return(NotFound());
        }