Пример #1
0
        public async Task <ApiResult <bool> > UpdateReminder(UpdateMaterialReminder bundle)
        {
            var materials = await _context.Materials.FindAsync(bundle.Id);

            if (materials == null)
            {
                return(new ApiErrorResult <bool>("Nguyên vật liệu không tồn tại"));
            }

            if (bundle.BoolReminder)
            {
                materials.Reminder = true;
                materials.Min      = bundle.Min;
                materials.Max      = bundle.Max;

                var str = bundle.DateReminder.Split(" - ");
                materials.ReminderStartDate = Convert.ToDateTime(str[0]);
                materials.ReminderEndDate   = Convert.ToDateTime(str[1]);
            }
            else
            {
                materials.Reminder = false;
            }

            _context.Materials.Update(materials);
            await _context.SaveChangesAsync();

            return(new ApiSuccessResult <bool>());
        }
Пример #2
0
        public async Task <ApiResult <bool> > UpdateReminder(int id, UpdateMaterialReminder bundle)
        {
            var json        = JsonConvert.SerializeObject(bundle);
            var httpContent = new StringContent(json, Encoding.UTF8, "application/json");
            var url         = $"/api/Material/reminder/" + $"{id}";
            var result      = await Update <bool>(url, httpContent);

            return(result);
        }
Пример #3
0
        public async Task <IActionResult> Update(int id, [FromBody] UpdateMaterialReminder request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _materialService.UpdateReminder(request);

            if (!result.IsSuccessed)
            {
                return(BadRequest(result));
            }

            return(Ok(result));
        }
Пример #4
0
        public async Task <ApiResult <bool> > UpdateReminder(UpdateMaterialReminder bundle)
        {
            var data = await _materialApiClient.UpdateReminder(bundle.Id, bundle);

            return(data);
        }