Exemplo n.º 1
0
        public IHttpActionResult PutManSalary(int id, ManSalary manSalary)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != manSalary.Id)
            {
                return(BadRequest());
            }

            db.Entry(manSalary).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ManSalaryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "Id,ManagerId,SalaryAmn,Date")] ManSalary manSalary)
 {
     if (ModelState.IsValid)
     {
         db.Entry(manSalary).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ManagerId = new SelectList(db.Managers, "Id", "Name", manSalary.ManagerId);
     return(View(manSalary));
 }
Exemplo n.º 3
0
        public IHttpActionResult GetManSalary(int id)
        {
            ManSalary manSalary = db.ManSalaries.Find(id);

            if (manSalary == null)
            {
                return(NotFound());
            }

            return(Ok(manSalary));
        }
Exemplo n.º 4
0
        public IHttpActionResult PostManSalary(ManSalary manSalary)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ManSalaries.Add(manSalary);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = manSalary.Id }, manSalary));
        }
Exemplo n.º 5
0
        public ActionResult DeleteConfirmed(int id)
        {
            ManSalary manSalary = db.ManSalaries.Find(id);

            int     ManId = manSalary.ManagerId;
            Manager m1    = db.Managers.Find(ManId);

            m1.Salary = m1.Salary - manSalary.SalaryAmn;

            db.ManSalaries.Remove(manSalary);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 6
0
        public IHttpActionResult DeleteManSalary(int id)
        {
            ManSalary manSalary = db.ManSalaries.Find(id);

            if (manSalary == null)
            {
                return(NotFound());
            }

            db.ManSalaries.Remove(manSalary);
            db.SaveChanges();

            return(Ok(manSalary));
        }
Exemplo n.º 7
0
        // GET: ManSalaries/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ManSalary manSalary = db.ManSalaries.Find(id);

            if (manSalary == null)
            {
                return(HttpNotFound());
            }
            return(View(manSalary));
        }
Exemplo n.º 8
0
        // GET: ManSalaries/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ManSalary manSalary = db.ManSalaries.Find(id);

            if (manSalary == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ManagerId = new SelectList(db.Managers, "Id", "Name", manSalary.ManagerId);
            return(View(manSalary));
        }
Exemplo n.º 9
0
        public ActionResult Create([Bind(Include = "Id,ManagerId,SalaryAmn,Date")] ManSalary manSalary)
        {
            if (ModelState.IsValid)
            {
                Manager m1 = db.Managers.Find(manSalary.ManagerId);
                m1.Salary = m1.Salary + manSalary.SalaryAmn;

                db.ManSalaries.Add(manSalary);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ManagerId = new SelectList(db.Managers, "Id", "Name", manSalary.ManagerId);
            return(View(manSalary));
        }
        public IHttpActionResult DeleteManSalary(int id)
        {
            ManSalary manSalary = db.ManSalaries.Find(id);

            if (manSalary == null)
            {
                return(NotFound());
            }
            Manager man = new Manager();

            man        = db.Managers.Find(manSalary.ManagerId);
            man.Salary = man.Salary - manSalary.SalaryAmn;

            db.ManSalaries.Remove(manSalary);
            db.SaveChanges();

            return(Ok(manSalary));
        }