public static string TranslateDay(EnumList.Days day, EnumList.Language language) { switch (day) { case EnumList.Days.Saturday: switch (language) { case EnumList.Language.Norwegian: return("Lørdag"); case EnumList.Language.English: return("Saturday"); case EnumList.Language.Arabic: return("السبت"); default: return(""); } case EnumList.Days.Sunday: switch (language) { case EnumList.Language.Norwegian: return("Søndag"); case EnumList.Language.English: return("Sunday"); case EnumList.Language.Arabic: return("الأحد"); default: return(""); } case EnumList.Days.Monday: switch (language) { case EnumList.Language.Norwegian: return("Mandag"); case EnumList.Language.English: return("Monday"); case EnumList.Language.Arabic: return("الاثنين"); default: return(""); } case EnumList.Days.Tuesday: switch (language) { case EnumList.Language.Norwegian: return("Tirsdag"); case EnumList.Language.English: return("Tuesday"); case EnumList.Language.Arabic: return("الثلاثاء"); default: return(""); } case EnumList.Days.Wednesday: switch (language) { case EnumList.Language.Norwegian: return("Onsdag"); case EnumList.Language.English: return("Wednesday"); case EnumList.Language.Arabic: return("الأربعاء"); default: return(""); } case EnumList.Days.Thursday: switch (language) { case EnumList.Language.Norwegian: return("Torsdag"); case EnumList.Language.English: return("Thursday"); case EnumList.Language.Arabic: return("الخميس"); default: return(""); } case EnumList.Days.Friday: switch (language) { case EnumList.Language.Norwegian: return("Fredag"); case EnumList.Language.English: return("Friday"); case EnumList.Language.Arabic: return("الجمعة"); default: return(""); } default: return(""); } }
public IActionResult Update(string lectureId, string courseId, string title, string description, string preparation, bool completed, bool free, TimeSpan from, TimeSpan to, EnumList.Days day, DateTime lectureDate) { //Check if the day match the date if (_context.Lectures.Where(x => x.CourseId == courseId).Where(x => x.Id != lectureId).Any(x => x.Date == lectureDate)) { // return BadRequest("The date already taken"); return(BadRequest("dateTaken")); } if (lectureDate.DayOfWeek.ToString() != day.ToString()) { return(BadRequest("dayNotMatch")); } if (to < from) { return(BadRequest("endTimeHigher")); } var lecture = _lectureService.GetLecture(lectureId); if (lecture == null) { return(BadRequest("errorHappened")); } var oldDate = lecture.Date; lecture.Title = title; lecture.Description = description; lecture.Preparation = preparation; lecture.Completed = completed; lecture.Free = free; lecture.Day = day; lecture.Date = lectureDate; lecture.From = from; lecture.To = to; try { _context.Lectures.Update(lecture); _context.SaveChanges(); } catch { return(BadRequest("errorHappened")); } if (oldDate != lectureDate) { _courseService.ReorderCourseLectures(lecture.CourseId); } return(Ok()); }