Exemple #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));
        }
Exemple #2
0
        public ActionResult Create([Bind(Include = "ProgrammerID,Name,Surname")] Programmer programmer)
        {
            if (ModelState.IsValid)
            {
                db.Programmers.Add(programmer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(programmer));
        }
        public ActionResult Create([Bind(Include = "AssignmentID,Job,DeadLineDate")] Assignment assignment)
        {
            if (ModelState.IsValid)
            {
                db.Assignments.Add(assignment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(assignment));
        }
Exemple #4
0
        public ActionResult Create([Bind(Include = "CompanyID,Company_Name")] Company company)
        {
            if (ModelState.IsValid)
            {
                db.Companies.Add(company);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(company));
        }
        public ActionResult Create([Bind(Include = "DepartmentID,Department_Type")] Department department)
        {
            if (ModelState.IsValid)
            {
                db.Departments.Add(department);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(department));
        }
Exemple #6
0
 private void TearDownData()
 {
     dataContext.Set <TestModel>().RemoveRange(dataContext.Set <TestModel>());
     context.Set <Log>().RemoveRange(context.Set <Log>());
     context.SaveChanges();
     dataContext.SaveChanges();
 }
Exemple #7
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();
        }
Exemple #8
0
        public void Update_UpdatesNotAttachedModel()
        {
            TestModel expected = ObjectFactory.CreateTestModel();

            context.Set <TestModel>().Add(expected);
            context.SaveChanges();

            expected.Text += "Test";
            context        = new TestingContext();
            repository     = new Repository <TestModel>(context);
            repository.Update(expected);
            context.SaveChanges();

            TestModel actual = context.Set <TestModel>().SingleOrDefault();

            TestHelper.PropertyWiseEqual(expected, actual);
        }
Exemple #9
0
 public virtual void Log(String message)
 {
     context.Set <Log>().Add(new Log(message));
     context.SaveChanges();
 }
Exemple #10
0
 public int Complete()
 {
     return(_aContext.SaveChanges());
 }
Exemple #11
0
 public virtual void Save()
 {
     context.SaveChanges();
 }
Exemple #12
0
        public void GetById_GetsModelById()
        {
            TestModel testModel = ObjectFactory.CreateTestModel();

            context.Set <TestModel>().Add(testModel);
            context.SaveChanges();

            TestModel expected = context.Set <TestModel>().SingleOrDefault();
            TestModel actual   = repository.GetById(testModel.Id);

            Assert.AreSame(expected, actual);
        }
Exemple #13
0
 private void SetUpData()
 {
     model = ObjectFactory.CreateRole();
     context.Set <Role>().Add(model);
     context.SaveChanges();
 }
Exemple #14
0
 private void TearDownData()
 {
     context.Set <Log>().RemoveRange(context.Set <Log>());
     context.SaveChanges();
 }