public int CreateOrder([FromBody] Order order) { _orderRepository.Create(order); var e = new Event(EventType.OrderCreated, new { order.OrderId }); _eventService.Add(e); return(order.OrderId); }
public ActionResult Create(Event model) { try { CheckAdminDepartment(); ValidateDateAndTime(model); ValidateEventNumber(model); if (ModelState.IsValid) { model.WeekDays = string.Join(",", model.DaysOfWeek); EventService.Add(model); EventService.SaveChanges(); } else { return(View(model)); } // TODO: Add insert logic here return(RedirectToAction("Index")); } catch (Exception ex) { return(View(model)); } }
public async Task <IActionResult> Create(Event viewModel, string[] EventTags, ICollection <IFormFile> files) { if (User.IsInRole(Roles.Client) || !User.Identity.IsAuthenticated) { return(NotFound()); } if (ModelState.IsValid) { await _eventMediaService.Add(viewModel, files); await _eventTagService.Add(viewModel, EventTags); var Id = await _eventService.Add(viewModel); if (!String.IsNullOrEmpty(Request.Form["continue"])) { return(RedirectToAction("Edit", new { Id = Id })); } if (!String.IsNullOrEmpty(Request.Form["new"])) { return(RedirectToAction(nameof(Create))); } return(RedirectToAction(nameof(Index))); } var eventLocations = await _eventLocationService.GetAll(); ViewBag.EventLocations = new SelectList(eventLocations.ToList(), "Id", "Title", viewModel.EventLocationId); return(View(viewModel)); }
public ActionResult Create(EventModel eventModel) { if (!ModelState.IsValid) { return(Json(new { message = Localization.Localization.ErrorModelValidation, success = false })); } eventModel.UserId = User.Identity.GetUserId(); try { lock (_lock) { _eventService.Add(eventModel); } } catch (RoomIsBusyException) { return(Json(new { message = Localization.Localization.ErrorRoomIsBusy, success = false })); } catch (RoomCapacityException) { return(Json(new { message = Localization.Localization.ErrorRoomCapacityLessOne, success = false })); } catch (Exception) { return(Json(new { message = Localization.Localization.ErrorGeneralException, success = false })); } return(Json(new { message = Localization.Localization.InfoEventAddedSuccess, success = true })); }
public ActionResult Create(EventModel em, HttpPostedFileBase Image) { Event ev = new Event(); // int somcateg = EventService.Sumpercategory(ev.Category); // ViewBag.cat = somcateg; ev.Name = em.Name; ev.AdminConfirmtion = false; ev.Category = em.Category; ev.DateEvent = em.DateEvent; ev.Description = em.Description; ev.image = Image.FileName; ev.number_P = em.number_P; ev.HeureD = em.HeureD; ev.HeureF = em.HeureF; ev.DirecteurFk = (int)Session["idu"]; EventService.Add(ev); EventService.Commit(); var path2 = Path.Combine(Server.MapPath("~/Content/Uploads"), Image.FileName); Image.SaveAs(path2); return(RedirectToAction("Index")); }
public async Task <IActionResult> AddEvent(EventModel model) { User user = profileManager.FindByUserName(User.Identity.Name); if (model.DateFrom < DateTime.Now) { ModelState.AddModelError("", "Wrong Date of Beginning"); } else { if (model.DateFrom > model.DateTo) { ModelState.AddModelError("", "Wrong Date of End"); } else { EventDTO eventDTO = mapper.Map <EventModel, EventDTO>(model); eventDTO.UserId = user.Id; await eventService.Add(eventDTO); return(RedirectToAction("Profile", "Profile")); } } model.Categories = categoryService.Categories(); return(View(model)); }
public JsonResult SaveEvent(Event e) { var status = false; string userId = User?.Identity?.GetUserId(); if (e.EventId > 0) { var v = eventService.Get(e.EventId); if (v != null) { if (v.Status != EventStatus.Onaylandı) { if (!string.IsNullOrEmpty(userId)) { if (userId != v.UserId) { return(new JsonResult { Data = new { status = false, message = "Bu kaydı güncellemeye yetkiniz yoktur!" } }); } e.UserId = userId; } if (e.IsFullDay == true) { e.EndDate = e.StartDate.Date + new TimeSpan(18, 00, 00); } e.ReservationDate = DateTime.Now; eventService.Update(e); } else { return(new JsonResult { Data = new { status = false, message = "Onaylanan kaydı güncelleyemezsiniz!" } }); } } } else { e.ReservationDate = DateTime.Now; e.ApproveDate = null; e.Status = EventStatus.Bekliyor; if (!string.IsNullOrEmpty(userId)) { e.UserId = userId; } if (e.IsFullDay == true) { e.EndDate = e.StartDate.Date + new TimeSpan(18, 00, 00); } eventService.Add(e); } status = true; return(new JsonResult { Data = new { status = status } }); }
public IActionResult Post(EventDTO evnt) { var result = _eventService.Add(evnt); evnt.Id = result; return(CreatedAtRoute("GetEventById", new { id = evnt.Id }, evnt)); }
public async Task <int> CreateEvent([FromBody] EventModel eventModel) { ValidateEventModel(eventModel); var eventEntity = _mapper.Map <Event>(eventModel); return(await _eventService.Add(eventEntity)); }
public async Task <long> CreateEvent(EventCreateRequest request) { var createdEvent = Event.Create(request); createdEvent.AuthorId = UserId; await _eventService.Add(createdEvent); return(createdEvent.Id); }
public void Post([FromBody] Event @event, string userId) { @event.Id = ObjectId.GenerateNewId().ToString(); _eventService.Add(@event); var user = _userService.Get(userId); user.EventCreated.Add(@event.Id); _userService.Update(user, user.Id); }
public IHttpActionResult Add(domain.Event domainEvent) { if (domainEvent == null) { return(BadRequest("Invalid Request")); } _eventService.Add(domainEvent); return(Ok()); }
public ValidationAppResult Add(EventViewModel eventViewModel) { var eventObj = Mapping.EventMapper.FromViewModelToDomain(eventViewModel); var result = eventService.Add(eventObj); Commit(); return(FromDomainToApplicationResult(result)); }
public IActionResult Create(EventCreateInputModel model) { if (!ModelState.IsValid) { return(View(model)); } eventService.Add(model); return(RedirectToAction("All")); }
public ActionResult CreateEvent([Bind(Include = "EventId,DateDebut,DateFin,Description,Titre,Adresse,Capacite")] Event @event) { if (ModelState.IsValid) { eventService.Add(@event); eventService.Commit(); return(RedirectToAction("Index")); } return(View("Event/Create", @event)); }
public async Task <IActionResult> Create(AddEventViewModel model) { if (ModelState.IsValid) { _eventService.Add(model); return(RedirectToAction("Index")); } ViewBag.Locations = new SelectList(await _locationService.GetAll(), "LocationId", "Address"); return(View(model)); }
public ActionResult Create(EventTypeViewModel model) { if (!ModelState.IsValid) { return(View(model)); } _eventService.Add(new EventTypeDto { Name = model.Name }); return(RedirectToAction("Index")); }
public IActionResult Post([FromBody] Event newEvent) { try { return(Ok(_eventService.Add(newEvent).ToApiModel())); } catch (Exception ex) { ModelState.AddModelError("AddEvent", ex.Message); return(BadRequest(ModelState)); } }
public IActionResult Add(AddOrUpdateEventViewModel viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } var eventId = Guid.NewGuid(); _eventService.Add(eventId, viewModel.Name, viewModel.Category, viewModel.Price); _eventService.AddTickets(eventId, viewModel.TicketsCount); return(RedirectToAction(nameof(Index), new { eventPage = 1 })); }
public override void OnReceive(Context context, Intent intent) { _workStorage = AndroidObjectFactory.GetWorkStorage(context); _userStorage = AndroidObjectFactory.GetUserStorage(context); _eventService = AndroidObjectFactory.GetEventService(); if (!(_userStorage.GetIsLoggedIn() & (!_workStorage.GetIsAtWork()))) { return; } _workStorage.SaveEntryDate(DateTime.Now); _workStorage.SaveAtWork(true); _eventService.Add(new StartWorkEvent(DateTime.Now)); }
public void Seed() { for (var i = 1; i < 11; i++) { var eventId = Guid.NewGuid(); _eventService.Add(eventId, $"Event{i}", "darmowe", i * 12); _eventService.AddTickets(eventId, 5); } //for (var i = 1; i < 5; i++) //{ // _productService.Add($"Product{i}"); //} }
public async Task <object> Create(string name, string strDateTime, string jsonTeams) { var teams = _serializer.Deserialize <ICollection <Team> >(jsonTeams); DateTime.TryParse(strDateTime, out DateTime dateTime); var newEvent = new Event() { DataTime = dateTime, Name = name, Teams = teams }; return(Map(await _service.Add(newEvent))); }
private async void SubmitButton_Click(object sender, RoutedEventArgs e) { try { if (Validate() == true) { DateTime scheduledOn = (DateTime)Date.SelectedDate; DateTime time = DateTime.ParseExact(Time.Text, "HH:mm", System.Globalization.CultureInfo.InvariantCulture); scheduledOn = scheduledOn.Add(time.TimeOfDay); int idCity = (await cityService.GetByUniqueIdentifiers(new string[] { "Name" }, new City() { Name = Shared.Config.Properties.Default.City })).IdCity; Event @event = new Event() { IdCategory = ((CategoryViewModel)Category.SelectedItem).IdCategory, IdAddress = ((AddressViewModel)Address.SelectedItem).IdAddress, Name = Name.Text, Description = Description.Text, ScheduledOn = scheduledOn, Organizers = Organizers.Text, IdCity = idCity, Duration = int.Parse(Duration.Text) }; DbStatus status = await eventService.Add(@event); if (status == DbStatus.EXISTS) { ShowMessage("Already exists!", "Error"); } else if (status == DbStatus.DATABASE_ERROR) { ShowMessage("Item was not added! ", "Error"); } else { ShowMessage("Successfully added!", "Success"); this.Close(); } } } catch (FormatException) { MessageBox.Show("Incorrect format! ", "Error"); } }
public override void OnReceive(Context context, Intent intent) { _userStorage = AndroidObjectFactory.GetUserStorage(context); _workStorage = AndroidObjectFactory.GetWorkStorage(context); _eventService = AndroidObjectFactory.GetEventService(); if (!(_userStorage.GetIsLoggedIn()) & _workStorage.GetIsAtWork()) { return; } _workStorage.SaveLeavingDate(DateTime.Now); _workStorage.SaveAtWork(false); _eventService.Add(new EndWorkEvent(DateTime.Now)); SummaryNotify(context); }
public async Task <IActionResult> Add(EventRequestResourceModel eventRequestResourceModel) { try { var eventId = await _eventService.Add(eventRequestResourceModel.Title, eventRequestResourceModel.ContentParagraph, eventRequestResourceModel.Position); return(StatusCode((int)HttpStatusCode.Created, new { Message = "Event was created successfully.", EventId = eventId })); } catch (EntityException e) { return(StatusCode((int)HttpStatusCode.UnprocessableEntity, new { e.Message, e.Code, Field = e.Field.ToLower() })); } }
public async Task <IActionResult> Post(Event model) { try { var eventModel = await _eventService.Add(model); if (eventModel == null) { return(BadRequest("Error Signing Up ")); } return(Ok(eventModel)); } catch (Exception ex) { return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Request Error: {ex.Message}")); } }
public ActionResult Create(EventViewModel @event) { if (ModelState.IsValid) { try { var eventDomain = Mapper.Map <EventViewModel, Event>(@event); eventAppService.Add(eventDomain); return(RedirectToAction("List")); } catch { return(View(@event)); } } return(View(@event)); }
public HttpResponseMessage Post(HttpRequestMessage request, Event e) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (ModelState.IsValid) { request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } else { var _event = _eventService.Add(e); _eventService.SaveChanges(); response = request.CreateResponse(HttpStatusCode.Created, _event); } return response; })); }
public async Task <IActionResult> Create(CreateEventViewModel @event) { if (ModelState.IsValid) { var newEvnet = new Event { Name = @event.Name, Place = @event.Place, StartTime = @event.StartTime, Description = @event.Description, ImageUrl = @event.ImageUrl, UserId = usermanager.GetUserId(User) }; events.Add(newEvnet); return(RedirectToAction(nameof(Index))); } // ViewData["UserId"] = usermanager.GetUserId(this.User); return(View(@event)); }
public JsonResult SaveEvent(EventVM e) { var status = false; if (e.EventID > 0) { //Update the event Event v = MyEventService.GetById(e.EventID); if (v != null) { v.Subject = e.Subject; v.Start = (DateTime)e.Start; v.End = e.End; v.Description = e.Description; v.IsFullDay = e.IsFullDay; v.ThemeColor = e.ThemeColor; MyEventService.Update(v); } } else { Event v = new Event() { Description = e.Description, End = e.End, IsFullDay = e.IsFullDay, Start = (DateTime)e.Start, Subject = e.Subject, ThemeColor = e.ThemeColor }; MyEventService.Add(v); } MyEventService.Commit(); status = true; return(new JsonResult { Data = new { status = status } }); }