Beispiel #1
0
        public async Task <IActionResult> Update(string id, [FromBody] SampleModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    model.UpdatedBy   = User.Identity.Name;
                    model.UpdatedDate = DateTime.Now;

                    await _operation.UpdateAsync(id, model);

                    return(new JsonResult("Save Successful"));
                }

                return(new JsonResult("Model is invalid")
                {
                    StatusCode = 400
                });
            }
            catch (Exception ex)
            {
                return(new JsonResult(ex)
                {
                    StatusCode = 400
                });
            }
        }
Beispiel #2
0
        public async Task Update(string id, SampleModel model)
        {
            model.UpdatedBy = "AspNetCore.MongoDB";

            model.UpdatedDate = DateTime.Now;

            await _operation.UpdateAsync(model.Id, model);
        }