Esempio n. 1
0
 // [BasicAuthentication]
 public HttpResponseMessage Put(Employee employee)
 {
     try
     {
         if (ModelState.IsValid)
         {
             //dynamic result = new ExpandoObject();
             employee.Created         = DateTime.Now;
             employee.Country         = null;
             employee.State           = null;
             employee.City            = null;
             dc.Entry(employee).State = EntityState.Modified;
             dc.SaveChanges();
             // result.Message = "Update successfully";
             // result.Id = employee.EmpID;
             return(Request.CreateResponse(HttpStatusCode.OK, employee.EmpID));
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Record Not Updated"));
         }
     }
     catch (Exception)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Record Not Updated"));
     }
 }
        public async Task <IActionResult> PutSignUpDetail(int id, SignUpDetail signUpDetail)
        {
            if (id != signUpDetail.ID)
            {
                return(BadRequest());
            }

            _context.Entry(signUpDetail).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SignUpDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 3
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"));
        }
Esempio n. 4
0
 public ActionResult Edit([Bind(Include = "ActorID,ActorName,ActorSex,ActorBio,ActorDOB")] Actor actor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(actor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(actor));
 }
 public ActionResult Edit([Bind(Include = "ProducerID,ProducerName,Bio,ProducerDob")] Producer producer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(producer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(producer));
 }
Esempio n. 6
0
 public ActionResult Edit([Bind(Include = "MovieID,ActorID,ProducerID,MovieName,MoviePlot,MovieRelease")] Movie movie)
 {
     if (ModelState.IsValid)
     {
         db.Entry(movie).State = EntityState.Modified;
         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 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));
        }