/// <summary> /// Create a new Event object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="userId">Initial value of the UserId property.</param> /// <param name="date">Initial value of the Date property.</param> /// <param name="hours">Initial value of the Hours property.</param> /// <param name="client">Initial value of the Client property.</param> /// <param name="currentStatus_Id">Initial value of the CurrentStatus_Id property.</param> /// <param name="description">Initial value of the Description property.</param> /// <param name="category_Id">Initial value of the Category_Id property.</param> public static Event CreateEvent(global::System.Int32 id, global::System.String userId, global::System.DateTime date, global::System.Double hours, global::System.String client, global::System.Int32 currentStatus_Id, global::System.String description, global::System.Int32 category_Id) { Event @event = new Event(); @event.Id = id; @event.UserId = userId; @event.Date = date; @event.Hours = hours; @event.Client = client; @event.CurrentStatus_Id = currentStatus_Id; @event.Description = description; @event.Category_Id = category_Id; return @event; }
public HttpResponseMessage UpdateEvent(Event item) { var match = this.context.Events.FirstOrDefault(e => e.Id == item.Id && e.UserId == item.UserId); if (match == null) { context.Events.AddObject(item);//.Add(item); } else { match.Hours = item.Hours; match.Category = item.Category; match.Client = item.Client; match.Status = item.Status; match.Date = item.Date; match.Description = item.Description; } context.SaveChanges(); if (match == null) { return new HttpResponseMessage(HttpStatusCode.Created); } else { return new HttpResponseMessage(HttpStatusCode.OK); } }
/// <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); }