Beispiel #1
0
        // [BasicAuthentication]
        public HttpResponseMessage Save(Employee Emp)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //dynamic result = new ExpandoObject();
                    Emp.Created = DateTime.Now;
                    dc.Employees.Add(Emp);
                    dc.SaveChanges();
                    // result.Message = "successfully insert";
                    //result.Id = Emp.EmpID;

                    return(Request.CreateResponse(HttpStatusCode.OK, Emp.EmpID));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, "Record Not Inserted"));
                }
            }
            catch (Exception)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "Record Not Inserted"));
            }
        }
Beispiel #2
0
        public Task <Person> Post(Person Person)
        {
            if (Person == null)
            {
                return(null);
            }
            var result = _context.PersonDetails.Add(Person);

            _context.SaveChanges();
            return(Task.FromResult(result));
        }
        public ActionResult Create([Bind(Include = "ActorID,ActorName,ActorSex,ActorBio,ActorDOB")] Actor actor)
        {
            if (ModelState.IsValid)
            {
                db.Actors.Add(actor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(actor));
        }
        public ActionResult Create([Bind(Include = "ProducerID,ProducerName,Bio,ProducerDob")] Producer producer)
        {
            if (ModelState.IsValid)
            {
                db.Producers.Add(producer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(producer));
        }
Beispiel #5
0
        public ActionResult Create([Bind(Include = "MovieID,ActorID,ProducerID,MovieName,MoviePlot,MovieRelease")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ActorID = new SelectList(db.Actors, "ActorID", "ActorName", movie.ActorID);

            ViewBag.ProducerID = new SelectList(db.Producers, "ProducerID", "ProducerName", movie.ProducerID);
            return(View(movie));
        }
        public IActionResult DeleteKeeperDB([FromBody] int kepId) //Удаление записи КЛАДОВЩИК из БД
        {
            Storekeeper b = _context.Storekeepers.Find(kepId);

            if (b == null)
            {
                return(Json("Запись удалена ранее. Обновите страницу!"));
            }
            var detail = _context.Details.FromSql("SELECT * From Details").ToList();
            int count  = detail.Count;

            for (int i = 0; i < count; i++)
            {
                if (b.Id == detail.ElementAt(i).StorekeeperId&& detail.ElementAt(i).Count != null && detail.ElementAt(i).Count != 0)
                {
                    return(Json("Запись не может быть удалена:за кладовщиком числятся детали!"));
                }
            }
            if (b != null)
            {
                _context.Storekeepers.Remove(b);
                _context.SaveChanges();
            }
            return(Json("Запись успешно удалена"));
        }
Beispiel #7
0
        public ActionResult createnew4(Student s)
        {
            DetailsContext obj = new DetailsContext();

            obj.Students.Add(s);
            obj.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #8
0
        public ActionResult edit(Student s)
        {
            DetailsContext obj      = new DetailsContext();
            Student        Students = obj.Students.Where(c => c.ID == s.ID).FirstOrDefault();

            obj.Entry(Students).CurrentValues.SetValues(s);
            obj.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #9
0
        public ActionResult delete(int id)
        {
            DetailsContext obj      = new DetailsContext();
            Student        Students = obj.Students.Where(c => c.ID == id).FirstOrDefault();

            obj.Students.Remove(Students);
            obj.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public void CreateDetails(Domain.Model.Details d)
 {
     using (DetailsContext context = new DetailsContext())
     {
         Details p = new Details()
         {
             Id        = d.id,
             FirstName = d.FirstName,
             LastName  = d.LastName
         };
         context.people.Add(p);
         context.SaveChanges();
     }
 }
        public JsonResult Insertemp(Employee emp)
        {
            dynamic result = new ExpandoObject();

            if (emp.Empid == 0)
            {
                var duplicate = dc.employees.Where(c => c.Email == emp.Email).ToList();

                if (duplicate.Count != 0)
                {
                    TempData["msg"] = "<script>alert('Already Exits!!!');</script>";
                    result.Message  = "already exits";
                }
                else
                {
                    emp.Create_date = DateTime.Now;
                    dc.employees.Add(emp);
                    dc.SaveChanges();
                    TempData["msg"] = "<script>alert('Insert successfully');</script>";
                    result.Message  = "successfully insert";
                }
            }
            else
            {
                emp.Create_date     = DateTime.Now;// dbEmployee.Create_date;
                dc.Entry(emp).State = EntityState.Modified;
                dc.SaveChanges();
                TempData["msg"] = "<script>alert('Update successfully');</script>";
                result.Message  = "successfully Updated";
            }


            //result.Message = string.Empty;
            result.Id = emp.Empid;

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
 public IActionResult AddDetail([FromBody] Detail detObj)
 {
     _context.Details.Add(detObj);
     _context.SaveChanges();
     return(Json("OK"));
 }
 public IActionResult AddKeeper([FromBody] Storekeeper kepObj)
 {
     _context.Storekeepers.Add(kepObj);
     _context.SaveChanges();
     return(Json("OK"));
 }