public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } VehicleType vt = vtRep.GetById(id); if (vt == null) { return(HttpNotFound()); } return(View(vt)); }
public void Delete(int id) { var entity = _vehicleTypeRepository.GetById(id); _vehicleTypeRepository.Delete(entity); _unitofwork.Commit(); }
private async Task <int> CalculateRentalCost(Vehicle vehicle, int days) { VehicleType type = await _vehicleTypeRepository.GetById(vehicle.VehicleTypeId); if (days <= type.DiscountAfterDays) { return(days * (int)type.DailyCost); } else { int cost = type.DiscountAfterDays * (int)type.DailyCost; int discountedDays = days - type.DiscountAfterDays; cost += (int)((float)discountedDays * (float)type.DailyCost * type.DiscountedPrice); return(cost); } }
public override VehicleType GetById(int id) { if (id == 0) { throw new Exception("Vehicle id is not provided!"); } return(_vehiclesTypeRepository.GetById(id)); }
public IActionResult Get(long id) { try { var model = repository.GetById(id); if (model == null) { return(NotFound(Constants.ErrorMessages.NotFoundEntity)); } return(Ok(model)); } catch (Exception ex) { logger.LogError(ex.GetExceptionMessages()); return(StatusCode(StatusCodes.Status500InternalServerError, Constants.ErrorMessages.FetchError)); } }
public async Task <VehicleType> GetById(int id) { var vehicleType = await _vehicleTypeRepository.GetById(id); if (vehicleType == null) { Response.StatusCode = 404; } return(vehicleType); }
public void Handle(AddVehicle command) { var userGroup = userGroupRepository.GetById(command.UserGroupId); var vehicleType = command.VehicleTypeId == null ? vehicleTypeRepository.GetById(command.VehicleTypeId) : null; var tenant = tenantRepository.GetById(userGroup.TenantId); var(vehicle, events) = tenant.CreateVehicle( command.LicensePlateId, vehicleType, command.Name); vehicleRepository.Create(vehicle); eventBus.Publish(events); }
public DateTime GetNextInspectionTime(int VehicleTypeId, string plate, int typeId, DateTime PurchaseDate) { DateTime nextInspectionTime = new DateTime(); //获取该类型车辆车检周期 VehicleType vehicleType = _vehicleTypeRepository.GetById(VehicleTypeId); //获取该车信息 VehicleInfo vehicleInfo = _vehicleInfoRepository.GetManay(o => o.Plate == plate).First(); string nowDate = DateTime.Now.ToShortDateString();//此次车检日期, 默认为当前日期 //如果typeId =1 并且 vehicleInfo是null 则表明该车是第一次车检 , 则用当前日期+检测周期作为下一次车检日期 if (typeId == 1 && vehicleType == null) { nextInspectionTime = DateTime.Now; } else { //购车日期+第一阶段周期 > 当前时间,说明还在第一阶段检车期 if (PurchaseDate.AddYears(vehicleType.FirstJY_Year) > DateTime.Parse(nowDate)) { //上一次的车检时间 加上周期内时间 就是下一次车检日期 nextInspectionTime = DateTime.Parse(vehicleInfo.LastInspectionTime.ToString()).AddMonths(vehicleType.FirstJY_Cycle); }//否则判断是否存在第三检测期, 若不存在 则按第二阶段计算下次车检日期 else if (vehicleType.LastJY_Year == 0) { nextInspectionTime = DateTime.Parse(vehicleInfo.LastInspectionTime.ToString()).AddMonths(vehicleType.SecondJY_Cycle); } else { //购车日期+第三阶段<当前日期 , 说明处于第二阶段 if (PurchaseDate.AddYears(vehicleType.LastJY_Year) > DateTime.Parse(nowDate)) { nextInspectionTime = DateTime.Parse(vehicleInfo.LastInspectionTime.ToString()).AddMonths(vehicleType.SecondJY_Cycle); } else { nextInspectionTime = DateTime.Parse(vehicleInfo.LastInspectionTime.ToString()).AddMonths(vehicleType.LastJY_Cycle); } } } return(nextInspectionTime); }
public IActionResult Delete(int id) { var _vehicle = _vehicletypeRepository.GetById(id); return(View(_vehicle)); }