private VehicleTypeDTO Create(VehicleTypeViewModel viewModel) { try { log.Debug(VehicleTypeViewModel.FormatVehicleTypeViewModel(viewModel)); VehicleTypeDTO vehicleType = new VehicleTypeDTO(); // copy values viewModel.UpdateDTO(vehicleType, null); //RequestContext.Principal.Identity.GetUserId()); // audit vehicleType.CreateBy = null; //RequestContext.Principal.Identity.GetUserId(); vehicleType.CreateOn = DateTime.UtcNow; // add log.Debug("_vehicleTypeService.AddVehicleType - " + VehicleTypeDTO.FormatVehicleTypeDTO(vehicleType)); int id = _vehicleTypeService.AddVehicleType(vehicleType); vehicleType.VehicleTypeId = id; log.Debug("result: 'success', id: " + id); return(vehicleType); } catch (Exception e) { // error log.Error(e.ToString()); throw; } }
public async Task <ActionResult> AddVehicleType([FromBody] VehicleType vehicleType) { var addVehicleTypeResult = await vehicleTypeService.AddVehicleType(vehicleType); if (!addVehicleTypeResult.IsSuccessful) { return(BadRequest(addVehicleTypeResult)); } return(Ok(addVehicleTypeResult)); }
public ActionResult AddVehicleType(string name) { if (string.IsNullOrWhiteSpace(name)) { ViewBag.Message = "请输入违章类型名称"; var _list = _vehicleTypeService.GetAll(); ViewBag.List = _list; return(View("Index")); } _vehicleTypeService.AddVehicleType(new VehicleType { VehicleTypeName = name }); return(RedirectToAction("Index")); }
public void AddVehicleType() { string type = commonMethods.ReadString("Enter the type of vehicle : "); bool isTypeAlreadyExists = IsTypeAlreadyExists(type); if (isTypeAlreadyExists) { Console.WriteLine("This vehicle type already exists!!"); int decision = commonMethods.ReadInt("Do you want to update the type " + type + " : 1. Yes 2. Go Back >> "); decision = commonMethods.IsValidChoice(decision); if (decision == 1) { UpdateVehicleType(); } else { commonMethods.FurtherAction(1); } } else { double maximumFare = commonMethods.ReadDouble("Enter the maximum fare allowed for " + type + " : "); while (maximumFare < 1) { maximumFare = commonMethods.ReadDouble("Please enter valid fare value : "); } int maximumSeats = commonMethods.ReadInt("Enter the maximum number of seats allowed for " + type + " : "); while (maximumSeats < 1) { maximumSeats = commonMethods.ReadInt("Please enter valid number of seats : "); } VehicleType vehicleType = new VehicleType() { Id = Guid.NewGuid().ToString(), Type = type, MaximumFare = maximumFare, MaximumSeats = maximumSeats }; vehicleTypeService.AddVehicleType(vehicleType); commonMethods.FurtherAction(1); } }
public bool AddVehicleType([FromBody] VehicleType vehicleType) { return(vehicleTypeService.AddVehicleType(vehicleType)); }