public IActionResult Edit(RubbishViewModel model) { var response = ResponseModelFactory.CreateInstance; if (ConfigurationManager.AppSettings.IsTrialVersion) { response.SetIsTrial(); return(Ok(response)); } using (_dbContext) { var entity = _dbContext.GrabageRoom.FirstOrDefault(x => x.GarbageRoomUuid == model.GarbageRoomUuid); entity.GarbageRoomUuid = model.GarbageRoomUuid; entity.VillageId = model.villageUuid; entity.Ljname = model.Ljname; entity.SystemUserUuid = model.SystemUserUuid; entity.StartTime = model.StartTime; entity.EndTime = model.EndTime; entity.Lon = model.Lon; entity.Lat = model.Lat; entity.State = model.State; entity.AddTime = model.AddTime; entity.CarId = model.CarId; entity.WingId = model.WingId; entity.Facilityuuid = model.Facilityuuid; _dbContext.SaveChanges(); return(Ok(response)); } }
public IActionResult Create(RubbishViewModel model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { var entity = new HaikanRefuseClassification.Api.Entities.GrabageRoom(); entity.GarbageRoomUuid = Guid.NewGuid(); if (_dbContext.GrabageRoom.Where(x => x.IsDelete == "0").Count(x => x.Ljname == model.Ljname) > 0) { response.SetFailed("垃圾箱房名字已存在"); return(Ok(response)); } //VillageId = _dbContext.Village.FirstOrDefault(x => x.Vname == model.Vname); entity.VillageId = model.villageUuid; //社区id entity.Ljname = model.Ljname; entity.SystemUserUuid = model.SystemUserUuid; //督导员id entity.StartTime = model.StartTime; entity.EndTime = model.EndTime; entity.Lon = model.Lon; entity.Lat = model.Lat; entity.AddTime = DateTime.Now.ToString("yyyy-MM-dd"); entity.AddPeople = AuthContextService.CurrentUser.DisplayName; entity.CarId = model.CarId; entity.IsDelete = "0"; entity.State = "0"; entity.WingId = model.WingId; entity.Facilityuuid = model.Facilityuuid; _dbContext.GrabageRoom.Add(entity); _dbContext.SaveChanges(); response.SetSuccess("添加成功"); return(Ok(response)); } }