コード例 #1
0
        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)));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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" }));
        }