public IActionResult CreateWithGet(string date, string comment, string employeeId, string version, string topicId) { //Adding to LearningDays LearningDay learningDay = new LearningDay(); learningDay.Date = DateTime.Parse(date.Replace('-', '.')); learningDay.Comment = comment; learningDay.EmployeeId = Int32.Parse(employeeId); learningDay.Version = Int32.Parse(version); db.LearningDays.Add(learningDay); db.SaveChanges(); //Adding to LearningDayTopics LearningDayTopic learningDayTopic = new LearningDayTopic(); learningDayTopic.LearningDayId = learningDay.Id; learningDayTopic.TopicId = Int32.Parse(topicId); learningDayTopic.Version = Int32.Parse(version); db.LearningDayTopics.Add(learningDayTopic); db.SaveChanges(); return(Json(Ok("Added"))); }
public IActionResult updateLearningDayTopic([FromBody] LearningDayTopic learningDayTopic) { if (learningDayTopic != null) { db.LearningDayTopics.Update(learningDayTopic); db.SaveChanges(); return(Json(Ok("LearningDayTopic updated"))); } else { return(NotFound("UPDATE: LearningDayTopic was not found")); } }
public IActionResult getLearningDayTopic(int id) { LearningDayTopic learningDayTopic = db.LearningDayTopics.Find(id); if (learningDayTopic != null) { return(Json(learningDayTopic)); } else { return(NotFound("GET: LearningDayTopic with ID = " + id + " was not found.")); } }
public IActionResult deleteLearningDayTopic(int id) { try { LearningDayTopic learningDayTopic = db.LearningDayTopics.Find(id); db.LearningDayTopics.Remove(learningDayTopic); db.SaveChanges(); return(Json(Ok("LearningDayTopic deleted"))); } catch (ArgumentNullException) { return(NotFound("DELETE: LearningDayTopic with ID = " + id + " was not found.")); } }
private void UpdateDayTopic( Domain.Entity.LearningCalendar.Employee employee, UpdateLearningDayOperationRequest.LearningDayTopic requestTopic, LearningDayTopic dayTopic) { var newStatus = MapProgressStatus(requestTopic); bool goalsShouldBeCompleted = newStatus != dayTopic.ProgressStatus && newStatus == ProgressStatus.Done; if (goalsShouldBeCompleted) { var targetGoal = employee.PersonalGoals .FirstOrDefault(goal => goal.TopicId == requestTopic.TopicId && !goal.IsComplete); targetGoal?.MarkAsComplete(); } dayTopic.ProgressStatus = newStatus; dayTopic.TopicId = requestTopic.TopicId; }