Ejemplo n.º 1
0
        public IHttpActionResult PutAssignment(int id, Assignment assignment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != assignment.AssignmentID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public void Update_DoesNotModifyEntityDate()
        {
            TestModel model = ObjectFactory.CreateTestModel();

            repository.Update(model);

            Assert.IsFalse(context.Entry(model).Property(prop => prop.EntityDate).IsModified);
        }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "ProgrammerID,Name,Surname")] Programmer programmer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(programmer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(programmer));
 }
Ejemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "AssignmentID,Job,DeadLineDate")] Assignment assignment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(assignment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(assignment));
 }
Ejemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "CompanyID,Company_Name")] Company company)
 {
     if (ModelState.IsValid)
     {
         db.Entry(company).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(company));
 }
Ejemplo n.º 6
0
        public void LoggableEntry_SetsEntityTypeThenEntityIsNotProxied()
        {
            entry = context.Entry(context.Set <Role>().Add(new Role()));

            Type actual   = new LoggableEntry(entry).EntityType;
            Type expected = model.GetType();

            Assert.AreNotEqual("System.Data.Entity.DynamicProxies", entry.Entity.GetType().Namespace);
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 7
0
        public void SetUp()
        {
            context = new TestingContext();
            TearDownData();
            SetUpData();

            context     = new TestingContext();
            entry       = context.Entry(context.Set <Role>().SingleOrDefault());
            entry.State = EntityState.Modified;
        }
Ejemplo n.º 8
0
 public ActionResult Edit([Bind(Include = "DepartmentID,Department_Type")] Department department)
 {
     if (ModelState.IsValid)
     {
         db.Entry(department).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(department));
 }
Ejemplo n.º 9
0
        public void LoggableEntry_HasChangesIfAnyAttachedPropertyIsModified()
        {
            context.Dispose();
            context = new TestingContext();

            model.Name += "1";
            context.Set <Role>().Attach(model);
            entry       = context.Entry <Role>(model);
            entry.State = EntityState.Modified;

            Assert.IsTrue(new LoggableEntry(entry).HasChanges);
        }
Ejemplo n.º 10
0
        public void SetUp()
        {
            context             = new TestingContext();
            dataContext         = new TestingContext();
            logger              = new EntityLogger(context);
            HttpContext.Current = new HttpMock().HttpContext;

            TearDownData();

            TestModel model = ObjectFactory.CreateTestModel();

            dataContext.Set <TestModel>().Add(model);
            entry = dataContext.Entry(model);
            dataContext.SaveChanges();
        }