//[AdminAuthorization] public IHttpActionResult PostSection(Section s, [FromUri] int id) { s.classid = id; secrepo.Insert(s); string url = Url.Link("GetSectionById", new { id = s.classid, id2 = s.sectionid }); s.HyperLinks.Add(new HyperLink() { HRef = "http://localhost:44347/api/admins/classes/" + s.classid + "/sections/" + s.sectionid, HttpMethod = "GET", Relation = "gET sECTION" }); s.HyperLinks.Add(new HyperLink() { HRef = "http://localhost:44347/api/admins/classes/" + s.classid + "/sections/", HttpMethod = "POST", Relation = "sELF" }); s.HyperLinks.Add(new HyperLink() { HRef = "http://localhost:44347/api/admins/classes/" + s.classid + "/sections/" + s.sectionid, HttpMethod = "PUT", Relation = "Edit Section" }); s.HyperLinks.Add(new HyperLink() { HRef = "http://localhost:44347/api/admins/classes/" + s.classid + "/sections/" + s.sectionid, HttpMethod = "DELETE", Relation = "Delete Section" }); return(Created(url, s)); }
protected async override void OnNavigatedTo(NavigationEventArgs e) { ISectionRepository sectionRepo = new SectionRepository(); await sectionRepo.Insert(new Section() { SectionName = "Section1", Students = new List<Student>() { new Student() { Name = "Student1" }, new Student() { Name = "Student2" } } }); var sections = await sectionRepo.GetAll(); base.OnNavigatedTo(e); }
/// <summary> /// inserts or updates a section object /// </summary> /// <param name="objSection">object section</param> /// <returns>returns true if operation successful</returns> public bool SaveSection(Section objSection) { try { SectionRepository sectionRepository = new SectionRepository(this.session); string section = objSection.Name; sectionRepository.Entity = objSection; if (sectionRepository.Entity.SectionId != null) { if (null != objSection.OldOrder && objSection.Sectionorder != null && objSection.Sectionorder != objSection.OldOrder) { sectionRepository.ChangeOrder(sectionRepository.Entity.Sectionorder.Value, objSection.OldOrder.Value); } sectionRepository.Update(); FriendlyurlRepository friendlyrepo = new FriendlyurlRepository(this.session); friendlyrepo.Entity.Id = sectionRepository.Entity.SectionId; friendlyrepo.Entity.Friendlyurlid = sectionRepository.Entity.Friendlyname; friendlyrepo.Entity.Type = Friendlyurl.FriendlyType.Section; friendlyrepo.Update(); InfoCache <List <Section> > cache = new InfoCache <List <Section> >(this.context) { TimeOut = 120 }; sectionRepository.Entity = new Section(); cache.SetCache("sections", sectionRepository.GetAll()); Utils.InsertAudit( this.session, new Audit() { Auditaction = "Update", Description = "Section -> " + section, Joindate = DateTime.Now, Username = (this.context.User as CustomPrincipal).UserId }); } else { sectionRepository.Entity.Sectionorder = sectionRepository.GetMaxOrder(); sectionRepository.Entity.Friendlyname = Utils.GetFindFrienlyName( this.session, sectionRepository.Entity.Name, sectionRepository.Entity.Sectionorder.Value); sectionRepository.Entity.SectionId = Convert.ToInt32(sectionRepository.Insert()); FriendlyurlRepository friendlyrepo = new FriendlyurlRepository(this.session); friendlyrepo.Entity.Id = sectionRepository.Entity.SectionId; friendlyrepo.Entity.Friendlyurlid = sectionRepository.Entity.Friendlyname; friendlyrepo.Entity.Type = Friendlyurl.FriendlyType.Section; friendlyrepo.Entity.LanguageId = sectionRepository.Entity.LanguageId; friendlyrepo.Insert(); Utils.InsertAudit( this.session, new Audit() { Auditaction = "Insert", Description = "Section -> " + section, Joindate = DateTime.Now, Username = (this.context.User as CustomPrincipal).UserId }); } return(true); } catch (Exception ex) { Utils.InsertLog( this.session, "Insert Section", ex.Message + " - " + ex.StackTrace); return(false); } }
public JsonResult Insert(SectionModal sectionObject) { return(Json(_databaseConnection.Insert(sectionObject), JsonRequestBehavior.AllowGet)); }