Exemplo n.º 1
0
        public async Task <IActionResult> Create_Or_Update(MotorTypes inputModel)
        {
            try
            {
                if (string.IsNullOrEmpty(inputModel.Name))
                {
                    throw new Exception($"Tên {MessageConst.NOT_EMPTY_INPUT}");
                }
                if (inputModel.Id == 0)
                {
                    var data = await _motorTypesManager.Create(inputModel);

                    return(Json(new { Result = true, Message = "Thêm mới dữ liệu thành công", data = data }));
                }
                else
                {
                    await _motorTypesManager.Update(inputModel);

                    return(Json(new { Result = true, Message = "Cập nhật dữ liệu thành công" }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Result = false, Message = ex.Message }));
            }
        }