/// <summary> /// 会议创建 /// </summary> /// <returns></returns> public ActionResult MeetingCreate() { CreateMeetingModel model = new CreateMeetingModel(); model = imeeting.GetCreteMeetingModel("0"); return(View(model)); }
public CreateMeetingModel GetCreteMeetingModel(string meetingId) { DataSet dataSet = MeetingDao.GetCreteMeetingModel(meetingId); CreateMeetingModel model = new CreateMeetingModel(); if (dataSet != null) { model.DepartList = new List <Depart>(); SetDeparList(model.DepartList, dataSet.Tables[0]); model.UserList = new List <User>(); SetUserList(model.UserList, dataSet.Tables[1]); } return(model); }
public IActionResult CreateMeeting([FromBody] CreateMeetingModel place) { if (place == null || place.Title == null || place.Country == null || place.City == null || place.Street == null || place.Number == null || place.Datepicker == null || place.TimeOC == null || place.TimeOC.Length != 2) { return(BadRequest("Invalid request")); } string get_email = ""; var identity = HttpContext.User.Identity as ClaimsIdentity; IEnumerable <Claim> claim = identity.Claims; var usernameClaim = claim .Where(x => x.Type == ClaimTypes.Name) .FirstOrDefault(); if (usernameClaim != null) { get_email = usernameClaim.Value; } if (get_email.Length < 1) { return(Unauthorized("Invalid user")); } Users user = LoadUser(get_email); if (user == null) { return(Unauthorized("Invalid user")); } if (place.Title.Length < 1) { return(Unauthorized("Missing title")); } if (place.Country.Length < 1) { return(Unauthorized("Missing country name")); } if (place.City.Length < 1) { return(Unauthorized("Missing city name")); } if (place.Street.Length < 1) { return(Unauthorized("Missing street name")); } if (place.Number.Length < 1) { return(Unauthorized("Missing number name")); } if (String.IsNullOrEmpty(place.Description)) { place.Description = null; } TimeSpan timeOpen = TimeSpan.Parse(place.TimeOC[0]); TimeSpan timeClose = TimeSpan.Parse(place.TimeOC[1]); if (timeOpen >= timeClose) { return(Unauthorized("Wrong time")); } using (var _context = new AppDBContext()) { using (var _contextTransaction = _context.Database.BeginTransaction()) { try { Place new_place = new Place(); new_place.id_user = user.id_user; new_place.title = place.Title; new_place.description = place.Description; new_place.multi_time = false; new_place.Place_data_onetime = new Place_data_onetime(); new_place.Place_data_onetime.start_date = DateTime.Parse( $"{place.Datepicker.Day}/{place.Datepicker.Month}/{place.Datepicker.Year} {place.TimeOC[0]}:00"); new_place.Place_data_onetime.end_date = DateTime.Parse( $"{place.Datepicker.Day}/{place.Datepicker.Month}/{place.Datepicker.Year} {place.TimeOC[1]}:00"); new_place.Place_address = new Place_address(); new_place.Place_address.country = place.Country; new_place.Place_address.city = place.City; new_place.Place_address.street = place.Street; new_place.Place_address.number = place.Number; _context.Place.Add(new_place); _context.SaveChanges(); _contextTransaction.Commit(); } catch { _contextTransaction.Rollback(); return(BadRequest("Can't create new event")); } } } return(Ok()); }