public async Task <IActionResult> SaveCollection([FromBody] JSCollection collection) { if (!this.HasRight("admincollections")) { return(Unauthorized()); } string token = this.GetToken(); if (!db.IsAuthenticated(token)) { return(Unauthorized()); } db.SaveCollection(collection); this.SaveUserAction(this.GetUserAction("Запис на колекция", JObject.FromObject(collection).ToString())); return(Ok()); }
public void SaveCollection(JSCollection collection) { Collection c; if (collection.CollectionId == 0) { c = new Collection(); db.Collection.Add(c); } else { c = db.Collection.First(x => x.CollectionId == collection.CollectionId); } c.Content = collection.Content; c.Name = collection.Name; c.Structure = collection.Structure; c.PortalPartId = collection.PortalPartId; db.SaveChanges(); }