public void UpdateWheel(SpecialSparepartViewModel specialSparepart, int userId) { DateTime serverTime = DateTime.Now; specialSparepart.ModifyDate = serverTime; specialSparepart.ModifyUserId = userId; SpecialSparepart entity = _specialSparepartRepository.GetById(specialSparepart.Id); Map(specialSparepart, entity); _specialSparepartRepository.AttachNavigation<Sparepart>(entity.Sparepart); _specialSparepartRepository.AttachNavigation<Reference>(entity.ReferenceCategory); _specialSparepartRepository.Update(entity); _unitOfWork.SaveChanges(); }
public void DeleteWheel(SpecialSparepartViewModel SpecialSparepart, int userId) { DateTime serverTime = DateTime.Now; List <SpecialSparepartDetail> details = _specialSparepartDetailRepository.GetMany(spd => spd.SpecialSparepartId == SpecialSparepart.Id).ToList(); foreach (var iDetails in details) { iDetails.Status = (int)DbConstant.DefaultDataStatus.Deleted; iDetails.ModifyDate = serverTime; iDetails.ModifyUserId = userId; _specialSparepartDetailRepository.Update(iDetails); } SpecialSparepart.Status = (int)DbConstant.DefaultDataStatus.Deleted; SpecialSparepart.ModifyDate = serverTime; SpecialSparepart.ModifyUserId = userId; SpecialSparepart entity = _specialSparepartRepository.GetById(SpecialSparepart.Id); Map(SpecialSparepart, entity); _specialSparepartRepository.Update(entity); _unitOfWork.SaveChanges(); }