public Mines(NaturalResources.NaturalResourcesType targResource) { type = NonShipEntityType.FACILITY; facilityType = FacilityType.MINE; targetResource = targResource; massPerUnit = 1000; volumePerUnit = 1000; }
public IActionResult Create(NaturalViewModel model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { if (_dbContext.NaturalResources.Any(x => x.Title == model.Title)) { response.SetFailed("标题名称已存在"); return(Ok(response)); } //var entity = _mapper.Map<NaturalViewModel, NaturalResources>(model); var entity = new NaturalResources(); entity.IsRelease = model.IsRelease; if (!string.IsNullOrEmpty(model.ReleaseTime.ToString())) { entity.ReleaseTime = Convert.ToDateTime(model.ReleaseTime); } entity.Title = model.Title; entity.Content = model.Content; entity.Cover = model.Cover; entity.NaturalResourcesUuid = Guid.NewGuid(); entity.IsDeleted = 0; entity.AddPeople = AuthContextService.CurrentUser.LoginName; entity.AddTime = DateTime.Now; entity.Photo = model.Photo; _dbContext.NaturalResources.Add(entity); int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("添加", "成功:添加:自然资源列表数据", _dbContext); } response.SetSuccess(); return(Ok(response)); } }