public bool CreateEvent(CreateEventModel createEventModel) { Event newEvent = new Event(); newEvent.Title = createEventModel.Title; newEvent.Description = createEventModel.Description; newEvent.StartTime = createEventModel.StartTime; newEvent.EndTime = createEventModel.EndTime; newEvent.IsPrivate = createEventModel.IsPrivate; newEvent.Category = GetCategory(createEventModel.CategoryString); newEvent.Location = CreateLocation(createEventModel.Latitude, createEventModel.Longitude, createEventModel.LocationName, createEventModel.Address); newEvent.IsActive = true; newEvent.LastModified = DateTime.Now; newEvent.Created = System.DateTime.Now; newEvent.Rating = 0; newEvent.CreatedBy = db.UserProfiles.Where(up => up.UserProfileId == createEventModel.UserProfileId).FirstOrDefault(); if (newEvent.CreatedBy != null) { db.AddToEvents(newEvent); db.SaveChanges(); return true; } else { return false; } }
/// <summary> /// Deprecated Method for adding a new object to the Events EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToEvents(Event @event) { base.AddObject("Events", @event); }
/// <summary> /// Create a new Event object. /// </summary> /// <param name="eventId">Initial value of the EventId property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="description">Initial value of the Description property.</param> /// <param name="rating">Initial value of the Rating property.</param> /// <param name="created">Initial value of the Created property.</param> /// <param name="lastModified">Initial value of the LastModified property.</param> /// <param name="startTime">Initial value of the StartTime property.</param> /// <param name="endTime">Initial value of the EndTime property.</param> /// <param name="isActive">Initial value of the IsActive property.</param> /// <param name="isPrivate">Initial value of the IsPrivate property.</param> /// <param name="createdById">Initial value of the CreatedById property.</param> public static Event CreateEvent(global::System.Int32 eventId, global::System.String title, global::System.String description, global::System.Int32 rating, global::System.DateTime created, global::System.DateTime lastModified, global::System.DateTime startTime, global::System.DateTime endTime, global::System.Boolean isActive, global::System.Boolean isPrivate, global::System.Int32 createdById) { Event @event = new Event(); @event.EventId = eventId; @event.Title = title; @event.Description = description; @event.Rating = rating; @event.Created = created; @event.LastModified = lastModified; @event.StartTime = startTime; @event.EndTime = endTime; @event.IsActive = isActive; @event.IsPrivate = isPrivate; @event.CreatedById = createdById; return @event; }
public static EventModel EventToEventModel(Event evt) { if (evt != null) { EventModel evtModel = new EventModel(); evtModel.EventId = evt.EventId; evtModel.Title = evt.Title; evtModel.Description = evt.Description; evtModel.StartTime = evt.StartTime; evtModel.EndTime = evt.EndTime; evtModel.Category = evt.Category; evtModel.IsPrivate = evt.IsPrivate; evtModel.Location = evt.Location; evtModel.IsActive = evt.IsActive; evtModel.LastModified = evt.LastModified; evtModel.Created = evt.Created; evtModel.Rating = evt.Rating; evtModel.CreatedById = evt.CreatedById; return evtModel; } else { return null; } }