public IHttpActionResult Put([FromBody] TYPE_MISSION type_mission, string apiKey) { if (type_mission != null) { var check = db.EMPLOYEEs.Where(x => x.apiKey.Equals(apiKey)).Select(x => x.level_employee).FirstOrDefault(); if (check) { var update = db.TYPE_MISSIONs.Where(x => x.id_type == type_mission.id_type).ToList(); update.ForEach(x => { x.name_type_mission = type_mission.name_type_mission; x.status = type_mission.status; }); db.SubmitChanges(); return(Ok(new { massage = "Sửa loại nhiệm vụ thành công!" })); } else { return(Ok(new { massage = "Không có quyền sửa!" })); } } else { return(Ok(new { massage = "Vui lòng nhập thông tin!" })); } }
// POST: Type_Mission/apiKey Thêm loại nhiệm vụ public IHttpActionResult Post([FromBody] TYPE_MISSION type_mission, [FromUri] string apiKey) { if (type_mission != null && apiKey != null) { var check = db.EMPLOYEEs.Where(x => x.apiKey == apiKey && x.status == true).Select(x => x.level_employee).FirstOrDefault(); if (check) { db.TYPE_MISSIONs.InsertOnSubmit(type_mission); db.SubmitChanges(); return(Ok(new { message = "Thêm loại nhiệm vụ thành công!" })); } else { return(Ok(new { message = "Không có quyền thêm!" })); } } else { return(Ok(new { message = "Vui lòng nhập loại nhiệm vụ" })); } }