public ResModel UpdatePartsAlertCount(PartsDictionaryDto partsDictionaryDto, UserDto operationUser) { using (var db = new ModelContext()) { var partsDictionary = db.PartsDictionary.FirstOrDefault(i => i.Id == partsDictionaryDto.Id); if (partsDictionary == null) { return(new ResModel() { Msg = "更新库存预警失败,未找到该库存档案", Success = false }); } try { partsDictionary.HighestAlertCount = partsDictionaryDto.HighestAlertCount; partsDictionary.LowestAlertCount = partsDictionaryDto.LowestAlertCount; db.SaveChanges(); } catch (Exception e) { return(new ResModel() { Msg = "更新库存预警失败", Success = false }); } return(new ResModel() { Msg = "更新库存预警成功", Success = true }); } }
public ResModel AddPartsDictionary(PartsDictionaryDto partsDictionaryDto, UserDto operationUser) { using (var db = new ModelContext()) { var partsDictionary = new PartsDictionary() { Id = Guid.NewGuid(), Name = partsDictionaryDto.Name, Code = partsDictionaryDto.Code, PartsTypeId = partsDictionaryDto.PartsTypeId, MeasurementUnit = partsDictionaryDto.MeasurementUnit, SupplierPrice = partsDictionaryDto.SupplierPrice, RetailPrice = partsDictionaryDto.RetailPrice, TradePrice = partsDictionaryDto.TradePrice, AdjustPrice = partsDictionaryDto.AdjustPrice, ClaimPrice = partsDictionaryDto.ClaimPrice, BrandName = partsDictionaryDto.BrandName, Specifications = partsDictionaryDto.Specifications, ProducedAddress = partsDictionaryDto.ProducedAddress, Label = partsDictionaryDto.Label, Description = partsDictionaryDto.Description }; var partsDictionaySuitedCarModels = partsDictionaryDto.PartsDictionarySuitedCarModelDtos.Select( i => new PartsDictionarySuitedCarModel() { Id = Guid.NewGuid(), PartsDictionaryId = partsDictionary.Id, BrandId = i.BrandId, SeriesId = i.SeriesId, ModelId = i.ModelId, CreateTime = DateTime.Now }); using (var scope = new TransactionScope()) { try { db.PartsDictionary.Add(partsDictionary); db.PartsDictionarySuitedCarModel.AddRange(partsDictionaySuitedCarModels); db.SaveChanges(); scope.Complete(); } catch (Exception e) { return(new ResModel() { Msg = "添加失败", Success = false }); } return(new ResModel() { Msg = "添加成功", Success = true }); } } }
public ResModel UpdatePartsAlertCount(PartsDictionaryDto partsDictionaryDto, UserDto operationUser) { return(_partsDictionaryRepository.UpdatePartsAlertCount(partsDictionaryDto, operationUser)); }
public ResModel AddPartsDictionary(PartsDictionaryDto partsDictionaryDto, UserDto operationUser) { return(_partsDictionaryRepository.AddPartsDictionary(partsDictionaryDto, operationUser)); }
public ActionResult Update(PartsDictionaryDto partsDictionaryDto) { var currentUser = Session["LogUser"] as UserDto; return(Json(_partsDictionaryService.UpdatePartsDictionary(partsDictionaryDto, currentUser))); }
public ResModel UpdatePartsDictionary(PartsDictionaryDto partsDictionaryDto, UserDto operationUser) { using (var db = new ModelContext()) { var partsDictionary = db.PartsDictionary.FirstOrDefault(i => i.Id == partsDictionaryDto.Id); if (partsDictionary == null) { return(new ResModel() { Msg = "更新失败,未找到该配件档案", Success = false }); } var partsDictionaySuitedCarModels = partsDictionaryDto.PartsDictionarySuitedCarModelDtos.Select( i => new PartsDictionarySuitedCarModel() { Id = Guid.NewGuid(), PartsDictionaryId = partsDictionary.Id, BrandId = i.BrandId, SeriesId = i.SeriesId, ModelId = i.ModelId, CreateTime = DateTime.Now }); using (var scope = new TransactionScope()) { try { partsDictionary.Name = partsDictionaryDto.Name; partsDictionary.Code = partsDictionaryDto.Code; partsDictionary.PartsTypeId = partsDictionaryDto.PartsTypeId; partsDictionary.MeasurementUnit = partsDictionaryDto.MeasurementUnit; partsDictionary.SupplierPrice = partsDictionaryDto.SupplierPrice; partsDictionary.RetailPrice = partsDictionaryDto.RetailPrice; partsDictionary.TradePrice = partsDictionaryDto.TradePrice; partsDictionary.AdjustPrice = partsDictionaryDto.AdjustPrice; partsDictionary.ClaimPrice = partsDictionaryDto.ClaimPrice; partsDictionary.BrandName = partsDictionaryDto.BrandName; partsDictionary.Specifications = partsDictionaryDto.Specifications; partsDictionary.ProducedAddress = partsDictionaryDto.ProducedAddress; partsDictionary.Label = partsDictionaryDto.Label; partsDictionary.Description = partsDictionaryDto.Description; db.PartsDictionarySuitedCarModel.RemoveRange(partsDictionary.PartsDictionarySuitedCarModel); db.SaveChanges(); db.PartsDictionarySuitedCarModel.AddRange(partsDictionaySuitedCarModels); db.SaveChanges(); scope.Complete(); } catch (Exception e) { return(new ResModel() { Msg = "更新失败", Success = false }); } return(new ResModel() { Msg = "更新成功", Success = true }); } } }