Пример #1
0
        public IHttpActionResult Postproject_messages(project_messages project_messages)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}

            db.project_messages.Add(project_messages);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = project_messages.pmid }, project_messages);
        }
        public IHttpActionResult Postproject_messages(project_messages project_messages)
        {
            Queries q = new Queries();

            project_messages.project_pid = projectsController.CurrentProjectId;

            project_messages.employee_eid = q.GetUserId();
            project_messages.messagetimestamp = DateTime.Now;

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.project_messages.Add(project_messages);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = project_messages.pmid }, project_messages);
        }
Пример #3
0
        public IHttpActionResult Postproject(project project)
        {
            project.pdate = DateTime.Now;
            project.employee_eid = q.GetUserId();

            db.projects.Add(project);

            db.SaveChanges();

            project_messages pm = new project_messages();

            pm.project_pid = project.pid;
            pm.projectmessage = "*** Verkefni stofnað ***";
            pm.messagetimestamp = DateTime.Now;
            pm.employee_eid = q.GetUserId();

            db.project_messages.Add(pm);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = project.pid }, project);
        }
Пример #4
0
        public IHttpActionResult Putproject_messages(int id, project_messages project_messages)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != project_messages.pmid)
            {
                return BadRequest();
            }

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }