public ActionResult Create([FromForm] CreateCalendarInputModel inputModel) { if (!this.TryValidateModel(inputModel)) { return(Ok(new ApiResultModel <int>(200, 10))); } var row = _calendarRepository.Create(inputModel); int status = 0; if (row == null) { status = 1; } return(Ok(new ApiResultModel <int>(200, status))); }
public bool Create(CreateCalendarInputModel inputModel) { DateTime starDate = DateTime.ParseExact(inputModel.StartDateTime.ToString(), "ddMMyyyyhhmm", CultureInfo.InvariantCulture); DateTime endDate = DateTime.ParseExact(inputModel.EndDateTime.ToString(), "ddMMyyyyhhmm", CultureInfo.InvariantCulture); var user = FindUser(inputModel.UserName); UtCalander row = new UtCalander() { AddbyUserId = inputModel.AddbyUserId, ClientName = inputModel.ClientName, CreatedDtime = new DateTime(), EndDtime = endDate, EventDescription = inputModel.EventDescription, EventName = inputModel.EventName, StartDtime = starDate, UserId = user.Id, EventId = Guid.NewGuid().ToString() }; _context.UtCalander.Add(row); return(true); }