public IActionResult Update([FromBody] CustomDayVM customDayVM) { if (customDayVM == null) { return(new BadRequestObjectResult(new { message = "Please provide a valid CustomDayVM" })); } return(new OkObjectResult(customDayRepo.UpdateCustomDay(customDayVM))); }
public bool UpdateCustomDay(CustomDayVM customDayVM) { CustomDay customDay = _context.CustomDays.Where(i => i.CustomDayId == customDayVM.CustomDayId).FirstOrDefault(); customDay.Name = customDayVM.Name; customDay.Description = customDayVM.Description; _context.SaveChanges(); return(true); }
public CustomDay CreateCustomDay(CustomDayVM customDay) { CustomDay newCustomDay = new CustomDay() { CustomDayId = GenerateCustomDayId(), Name = customDay.Name, Description = customDay.Description, UserId = Guid.Parse(customDay.UserId) }; _context.CustomDays.Add(newCustomDay); _context.SaveChanges(); return(newCustomDay); }
public IActionResult Create([FromBody] CustomDayVM customDayVM) { string userId = customDayVM.UserId; if (customDayVM == null) { return(new BadRequestObjectResult(new { message = "Please provide a valid CustomDayVM" })); } if (userId == null || userId == "") { return(new BadRequestObjectResult(new { message = "Please provide a UserId." })); } Guid userGuid; bool success = Guid.TryParse(userId, out userGuid); if (success) { return(new OkObjectResult(customDayRepo.CreateCustomDay(customDayVM))); } return(new BadRequestObjectResult(new { message = "UserId could not be parsed as a Guid" })); }