public IActionResult HotelinfoCreate(HotelinfoViewModel model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { var entity = new HaikanSmartTownCockpit.Api.Entities.Hotel(); entity.HotelUuid = Guid.NewGuid(); entity.HotelName = model.HotelName; entity.HotelLocation = model.HotelLocation; entity.HotelPhone = model.HotelPhone; entity.HotelPeoPle = model.HotelPeoPle; entity.Village = model.Village; if (model.HotelType == "") { entity.HotelType = "正常营业"; } else { entity.HotelType = model.HotelType; } entity.HotelRecommend = model.HotelRecommend; entity.AddTime = DateTime.Now.ToString("yyyy-MM-dd"); entity.AddPeople = AuthContextService.CurrentUser.DisplayName; //entity.AddTime = DateTime.Now.ToString("yyyy-MM-dd"); //entity.AddPeople = model.addPeople; entity.IsDeleted = 0; _dbContext.Hotel.Add(entity); int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("添加", "成功:添加:民宿信息一条数据", _dbContext); } response.SetSuccess("添加成功"); return(Ok(response)); } }
public IActionResult HotelinfoEdit(HotelinfoViewModel model) { var response = ResponseModelFactory.CreateInstance; string guid = model.HotelUuid; if (ConfigurationManager.AppSettings.IsTrialVersion) { response.SetIsTrial(); return(Ok(response)); } using (_dbContext) { var entity = _dbContext.Hotel.FirstOrDefault(x => x.HotelUuid == Guid.Parse(guid)); entity.HotelName = model.HotelName; entity.HotelLocation = model.HotelLocation; entity.Village = model.Village; if (model.HotelType == "") { entity.HotelType = "正常营业"; } else { entity.HotelType = model.HotelType; } entity.HotelPhone = model.HotelPhone; entity.HotelPeoPle = model.HotelPeoPle; entity.HotelRecommend = model.HotelRecommend; int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("编辑", "成功:编辑:民宿信息一条数据", _dbContext); } response.SetSuccess("修改成功"); return(Ok(response)); } }