public async Task <IActionResult> SaveHeader([FromBody] JSHeader header) { string token = this.GetToken(); if (!db.IsAuthenticated(token)) { return(Unauthorized()); } if (!this.HasRight("adminheaders")) { return(Unauthorized()); } db.SaveHeader(header); this.SaveUserAction(this.GetUserAction("Запис на заглавна част", JObject.FromObject(header).ToString())); return(Ok()); }
public void SaveHeader(JSHeader header) { Header h; if (header.HeaderId == 0) { h = ModelMapper.Instance.Mapper.Map <Header>(header); db.Header.Add(h); } else { h = db.Header.First(x => x.HeaderId == header.HeaderId); h.Content = header.Content; h.Title = header.Title; h.PortalPartId = header.PortalPartId; } db.SaveChanges(); }