private string AddBook() { book Book = (book)ObjectUtil.FillObjectWithMap(new book(), BaseService.ReqToDict(Request)); if (Book != null) { bookService = new BookService(); book BookDB = null; if (Book.id != null && Book.id != "") { BookDB = (book)bookService.Update(Book); } else { BookDB = (book)bookService.Add(Book); } if (BookDB == null) { return("0"); } book toSend = (book)ObjectUtil.GetObjectValues(new string[] { "id", "title", "publisher_id", "author_id", "category_id", "page", "review" }, BookDB); return(JsonConvert.SerializeObject(toSend)); } return("0"); }
private string AddStudent() { student Student = (student)ObjectUtil.FillObjectWithMap(new student(), BaseService.ReqToDict(Request)); if (Student != null) { studentService = new StudentService(); student Std = null; if (StringUtil.NotNullAndNotBlank(Student.id)) { Std = (student)studentService.Update(Student); } else { Std = (student)studentService.Add(Student); } if (Std == null) { return("0"); } student toSend = (student)ObjectUtil.GetObjectValues(new string[] { "id", "name", "bod", "class_id", "address", "email" }, Std); return(JsonConvert.SerializeObject(toSend)); } return("0"); }
private string AddPublisher() { publisher publisher = (publisher)ObjectUtil.FillObjectWithMap(new publisher(), BaseService.ReqToDict(Request)); if (publisher != null) { PublisherService = new PublisherService(); publisher Std = null; if (StringUtil.NotNullAndNotBlank(publisher.id)) { Std = (publisher)PublisherService.Update(publisher); } else { Std = (publisher)PublisherService.Add(publisher); } if (Std == null) { return("0"); } publisher toSend = (publisher)ObjectUtil.GetObjectValues(new string[] { "id", "name", "address", "contact" }, Std); return(JsonConvert.SerializeObject(toSend)); } return("0"); }
private string AddClass() { @class Class = (@class)ObjectUtil.FillObjectWithMap(new @class(), BaseService.ReqToDict(Request)); if (Class != null) { ClassService = new ClassService(); @class classDB = null; if (Class.id != null && Class.id != "") { classDB = (@class)ClassService.Update(Class); } else { classDB = (@class)ClassService.Add(Class); } if (classDB == null) { return("0"); } @class toSend = (@class)ObjectUtil.GetObjectValues(new string[] { "id", "class_name" }, classDB); return(JsonConvert.SerializeObject(toSend)); } return("0"); }
private string AddCategory() { category category = (category)ObjectUtil.FillObjectWithMap(new category(), BaseService.ReqToDict(Request)); if (category != null) { CategoryService = new CategoryService(); category categoryDB = null; if (category.id != null && category.id != "") { categoryDB = (category)CategoryService.Update(category); } else { categoryDB = (category)CategoryService.Add(category); } if (categoryDB == null) { return("0"); } category toSend = (category)ObjectUtil.GetObjectValues(new string[] { "id", "category_name" }, categoryDB); return(JsonConvert.SerializeObject(toSend)); } return("0"); }
public override Dictionary <string, object> ObjectList(int Offset, int Limit, List <Dictionary <string, object> > ObjectList) { int TotalCount = 0; List <publisher> publishers = new List <publisher>(); List <Dictionary <string, object> > publisherListMap = ObjectList; if (publisherListMap.Count == 0) { goto end; } foreach (Dictionary <string, object> publisherMap in publisherListMap) { if (publisherMap.Keys.Count == 1 && publisherMap.Keys.ElementAt(0).Equals("count")) { TotalCount = (int)publisherMap["count"]; break; } publisher publisher = (publisher)ObjectUtil.FillObjectWithMap(new publisher(), publisherMap); publishers.Add(publisher); } end: return(new Dictionary <string, object>() { { "totalCount", TotalCount }, { "data", publishers } }); }
public override Dictionary <string, object> ObjectList(int Offset, int Limit, List <Dictionary <string, object> > ObjectList) { int TotalCount = 0; List <book> Books = new List <book>(); List <Dictionary <string, object> > BookListMap = ObjectList; if (BookListMap.Count == 0) { goto end; } foreach (Dictionary <string, object> BookMap in BookListMap) { if (BookMap.Keys.Count == 1 && BookMap.Keys.ElementAt(0).Equals("count")) { TotalCount = (int)BookMap["count"]; break; } book Book = (book)ObjectUtil.FillObjectWithMap(new book(), BookMap); Books.Add(Book); } end: return(new Dictionary <string, object>() { { "totalCount", TotalCount }, { "data", Books } }); }
public override Dictionary <string, object> ObjectList(int Offset, int Limit, List <Dictionary <string, object> > ObjectList) { int TotalCount = 0; List <author> authors = new List <author>(); List <Dictionary <string, object> > authorListMap = ObjectList; if (authorListMap.Count == 0) { goto end; } foreach (Dictionary <string, object> authorMap in authorListMap) { if (authorMap.Keys.Count == 1 && authorMap.Keys.ElementAt(0).Equals("count")) { TotalCount = (int)authorMap["count"]; break; } author author = (author)ObjectUtil.FillObjectWithMap(new author(), authorMap); authors.Add(author); } end: return(new Dictionary <string, object>() { { "totalCount", TotalCount }, { "data", authors } }); }
public override Dictionary <string, object> ObjectList(int Offset, int Limit, List <Dictionary <string, object> > ObjectList) { int TotalCount = 0; List <category> categorys = new List <category>(); List <Dictionary <string, object> > categoryListMap = ObjectList; if (categoryListMap.Count == 0) { goto end; } foreach (Dictionary <string, object> categoryMap in categoryListMap) { if (categoryMap.Keys.Count == 1 && categoryMap.Keys.ElementAt(0).Equals("count")) { TotalCount = (int)categoryMap["count"]; break; } category category = (category)ObjectUtil.FillObjectWithMap(new category(), categoryMap); categorys.Add(category); } end: return(new Dictionary <string, object>() { { "totalCount", TotalCount }, { "data", categorys } }); }
public override Dictionary <string, object> ObjectList(int Offset, int Limit, List <Dictionary <string, object> > ObjectList) { int TotalCount = 0; List <Dictionary <string, object> > visitListMap = ObjectList; List <visit> visits = new List <visit>(); if (visitListMap.Count == 0) { goto end; } foreach (Dictionary <string, object> visitMap in visitListMap) { if (visitMap.Keys.Count == 1 && visitMap.Keys.ElementAt(0).Equals("count")) { TotalCount = (int)visitMap["count"]; break; } visit visit = (visit)ObjectUtil.FillObjectWithMap(new visit(), visitMap); visits.Add(visit); } end: return(new Dictionary <string, object>() { { "totalCount", TotalCount }, { "data", visits } }); }
public static book_issue GetByStudentAndRecId(student Student, string RecId, AppUser AppUser) { if (Student == null) { return(null); } Dictionary <string, object> Params = MixParamWithUnP( new Dictionary <string, object>() { { "Action", "getBookIssueByStudentId" }, { "student_id", Student.id }, { "rec_id", RecId } }, AppUser); Dictionary <string, object> RespParams = Request.PostReq(Transaction.URL, Params); if (RespParams != null && RespParams["result"] != null && RespParams["result"].ToString() == "0") { Dictionary <string, object> DataMap = StringUtil.JSONStringToMap(RespParams["data"].ToString()); Dictionary <string, object> BookIssueMap = StringUtil.JSONStringToMap(DataMap["book_issue"].ToString()); return((book_issue)ObjectUtil.FillObjectWithMap(new book_issue(), BookIssueMap)); } return(null); }
private string AddAuthor() { author author = (author)ObjectUtil.FillObjectWithMap(new author(), BaseService.ReqToDict(Request)); if (author != null) { AuthorService = new AuthorService(); author Std = null; if (StringUtil.NotNullAndNotBlank(author.id)) { Std = (author)AuthorService.Update(author); } else { Std = (author)AuthorService.Add(author); } if (Std == null) { return("0"); } author toSend = (author)ObjectUtil.GetObjectValues(new string[] { "id", "name", "address", "email", "phone" }, Std); return(JsonConvert.SerializeObject(toSend)); } return("0"); }
public override Dictionary <string, object> ObjectList(int Offset, int Limit, List <Dictionary <string, object> > ObjectList) { int TotalCount = 0; List <issue> issues = new List <issue>(); List <Dictionary <string, object> > issueListMap = ObjectList; if (issueListMap.Count == 0) { goto end; } foreach (Dictionary <string, object> issueMap in issueListMap) { if (issueMap.Keys.Count == 1 && issueMap.Keys.ElementAt(0).Equals("count")) { TotalCount = (int)issueMap["count"]; break; } issue issue = (issue)ObjectUtil.FillObjectWithMap(new issue(), issueMap); issue.appUser = AppUser; issues.Add(issue); } end: return(new Dictionary <string, object>() { { "totalCount", TotalCount }, { "data", issues } }); }
public override Dictionary <string, object> ObjectList(int Offset, int Limit, List <Dictionary <string, object> > ObjectList) { int TotalCount = 0; List <@class> @classs = new List <@class>(); List <Dictionary <string, object> > @classListMap = ObjectList; if (@classListMap.Count == 0) { goto end; } foreach (Dictionary <string, object> @classMap in @classListMap) { if (@classMap.Keys.Count == 1 && @classMap.Keys.ElementAt(0).Equals("count")) { TotalCount = (int)@classMap["count"]; break; } @class @class = (@class)ObjectUtil.FillObjectWithMap(new @class(), @classMap); @classs.Add(@class); } end: return(new Dictionary <string, object>() { { "totalCount", TotalCount }, { "data", @classs } }); }
public override Dictionary <string, object> ObjectList(int Offset, int Limit, List <Dictionary <string, object> > ObjectList) { int TotalCount = 0; List <Dictionary <string, object> > StudentListMap = ObjectList; List <student> Students = new List <student>(); if (StudentListMap.Count == 0) { goto end; } foreach (Dictionary <string, object> StudentMap in StudentListMap) { if (StudentMap.Keys.Count == 1 && StudentMap.Keys.ElementAt(0).Equals("count")) { TotalCount = (int)StudentMap["count"]; break; } student Student = (student)ObjectUtil.FillObjectWithMap(new student(), StudentMap); Student.AppUser = AppUser; Students.Add(Student); } end: return(new Dictionary <string, object>() { { "totalCount", TotalCount }, { "data", Students } }); }
public static student AddStudent(student Student, AppUser AppUser) { Dictionary <string, object> Params = ObjectUtil.FillMap(Student); Dictionary <string, object> RespPost = Transaction.PostInput(Transaction.URL, "addStudent", AppUser, Params); if (RespPost != null && RespPost["result"].ToString() == "0") { Dictionary <string, object> DataMap = StringUtil.JSONStringToMap(RespPost["data"].ToString()); Dictionary <string, object> StudentMap = StringUtil.JSONStringToMap(DataMap["student"].ToString()); student NewStudent = (student)ObjectUtil.FillObjectWithMap(new student(), StudentMap); return(NewStudent); } return(null); }
public static @class AddClass(@class @class, AppUser AppUser) { Dictionary <string, object> Params = ObjectUtil.FillMap(@class); Dictionary <string, object> RespPost = Transaction.PostInput(Transaction.URL, "addClass", AppUser, Params); if (RespPost != null && RespPost["result"].ToString() == "0") { Dictionary <string, object> DataMap = StringUtil.JSONStringToMap(RespPost["data"].ToString()); Dictionary <string, object> ClassMap = StringUtil.JSONStringToMap(DataMap["class"].ToString()); @class NewClass = (@class)ObjectUtil.FillObjectWithMap(new @class(), ClassMap); return(NewClass); } return(null); }
public static author AddAuthor(author author, AppUser AppUser) { Dictionary <string, object> Params = ObjectUtil.FillMap(author); Dictionary <string, object> RespPost = Transaction.PostInput(Transaction.URL, "addAuthor", AppUser, Params); if (RespPost != null && RespPost["result"].ToString() == "0") { Dictionary <string, object> DataMap = StringUtil.JSONStringToMap(RespPost["data"].ToString()); Dictionary <string, object> authorMap = StringUtil.JSONStringToMap(DataMap["author"].ToString()); author Newauthor = (author)ObjectUtil.FillObjectWithMap(new author(), authorMap); return(Newauthor); } return(null); }
public static category AddCategory(category category, AppUser AppUser) { Dictionary <string, object> Params = ObjectUtil.FillMap(category); Dictionary <string, object> RespPost = Transaction.PostInput(Transaction.URL, "addCategory", AppUser, Params); if (RespPost != null && RespPost["result"].ToString() == "0") { Dictionary <string, object> DataMap = StringUtil.JSONStringToMap(RespPost["data"].ToString()); Dictionary <string, object> categoryMap = StringUtil.JSONStringToMap(DataMap["category"].ToString()); category Newcategory = (category)ObjectUtil.FillObjectWithMap(new category(), categoryMap); return(Newcategory); } return(null); }
public static publisher AddPublisher(publisher publisher, AppUser AppUser) { Dictionary <string, object> Params = ObjectUtil.FillMap(publisher); Dictionary <string, object> RespPost = Transaction.PostInput(Transaction.URL, "addPublisher", AppUser, Params); if (RespPost != null && RespPost["result"].ToString() == "0") { Dictionary <string, object> DataMap = StringUtil.JSONStringToMap(RespPost["data"].ToString()); Dictionary <string, object> publisherMap = StringUtil.JSONStringToMap(DataMap["publisher"].ToString()); publisher Newpublisher = (publisher)ObjectUtil.FillObjectWithMap(new publisher(), publisherMap); return(Newpublisher); } return(null); }
public static book AddBook(book Book, AppUser AppUser) { Dictionary <string, object> Params = ObjectUtil.FillMap(Book); Dictionary <string, object> RespPost = Transaction.PostInput(Transaction.URL, "addBook", AppUser, Params); if (RespPost != null && RespPost["result"].ToString() == "0") { Dictionary <string, object> DataMap = StringUtil.JSONStringToMap(RespPost["data"].ToString()); Dictionary <string, object> BookMap = StringUtil.JSONStringToMap(DataMap["book"].ToString()); book NewBook = (book)ObjectUtil.FillObjectWithMap(new book(), BookMap); return(NewBook); } return(null); }
public ActionResult DivisionSvc() { bool Access = UserValid() && IsAdmin(); WebResponse Response = new WebResponse(); if (!Access || !StringUtil.NotNullAndNotBlank(Request.Form["Action"])) { return(Json(Response)); } string Action = Request.Form["Action"].ToString(); DivisionService EntitySvc = new DivisionService(); switch (Action) { case "List": Response = MVCUtil.generateResponseList(EntitySvc, Request, LoggedUser, new string[] { "id", "name", "description", "institution_id" }, typeof(division)); break; case "Form": Response = MVCUtil.generateResponseWithForm(typeof(division), EntitySvc, Request); break; case "Post": division Division = (division)ObjectUtil.FillObjectWithMap(new division(), BaseService.ReqToDict(Request)); if (Division != null) { Division.institution_id = LoggedUser.institution_id; string[] ObjParamToSend = new string[] { "id", "name", "description", "institution_id" }; Response = MVCUtil.UpdateEntity(EntitySvc, Division, ObjParamToSend, Response); } break; case "Delete": Response = MVCUtil.DeleteEntity(EntitySvc, Request, Response); break; default: break; } return(Json(Response)); }
public ActionResult EventSvc() { bool Access = UserValid(); WebResponse Response = new WebResponse(); if (!Access || !StringUtil.NotNullAndNotBlank(Request.Form["Action"])) { return(Json(Response)); } string Action = Request.Form["Action"].ToString(); EventService EntitySvc = new EventService(); switch (Action) { case "List": Response = MVCUtil.generateResponseList(EntitySvc, Request, LoggedUser, new string[] { "id", "program_id", "user_id", "date", "location", "participant", "info", "done", "name" }, typeof(@event)); break; case "Form": Response = MVCUtil.generateResponseWithForm(typeof(@event), EntitySvc, Request); break; case "Post": @event Event = (@event)ObjectUtil.FillObjectWithMap(new @event(), BaseService.ReqToDict(Request)); if (Event != null) { Event.user_id = LoggedUser.id; string[] ObjParamToSend = new string[] { "id", "program_id", "user_id", "date", "location", "participant", "info", "done", "name" }; Response = MVCUtil.UpdateEntity(EntitySvc, Event, ObjParamToSend, Response); } break; case "Delete": Response = MVCUtil.DeleteEntity(EntitySvc, Request, Response); break; default: break; } return(Json(Response)); }
public ActionResult UserSvc() { bool Access = UserValid() && IsAdmin(); WebResponse Response = new WebResponse(); if (LoggedUser.admin != 1 || !Access || !StringUtil.NotNullAndNotBlank(Request.Form["Action"])) { return(Json(Response)); } string Action = Request.Form["Action"].ToString(); UserService EntitySvc = new UserService(); switch (Action) { case "List": Response = MVCUtil.generateResponseList(EntitySvc, Request, LoggedUser, new string[] { "id", "name", "username", "password", "email" }, typeof(user)); break; case "Form": Response = MVCUtil.generateResponseWithForm(typeof(user), EntitySvc, Request); break; case "Post": user User = (user)ObjectUtil.FillObjectWithMap(new user(), BaseService.ReqToDict(Request)); User.institution_id = LoggedUser.institution_id; if (User != null) { Response = MVCUtil.UpdateEntity(EntitySvc, User, new string[] { "id", "name", "username", "password", "email" }, Response); } break; case "Delete": Response = MVCUtil.DeleteEntity(EntitySvc, Request, Response); break; default: break; } return(Json(Response)); }
public ActionResult ProgramSvc() { bool Access = UserValid(); WebResponse Response = new WebResponse(); if (!Access || !StringUtil.NotNullAndNotBlank(Request.Form["Action"])) { return(Json(Response)); } string Action = Request.Form["Action"].ToString(); ProgramService EntitySvc = new ProgramService(); switch (Action) { case "List": Response = MVCUtil.generateResponseList(EntitySvc, Request, LoggedUser, new string[] { "id", "name", "description", "sect_id" }, typeof(program)); break; case "Form": Response = MVCUtil.generateResponseWithForm(typeof(program), EntitySvc, Request); break; case "Post": program Program = (program)ObjectUtil.FillObjectWithMap(new program(), BaseService.ReqToDict(Request)); if (Program != null) { string[] ObjParamToSend = new string[] { "id", "name", "description", "sect_id" }; Response = MVCUtil.UpdateEntity(EntitySvc, Program, ObjParamToSend, Response); } break; case "Delete": Response = MVCUtil.DeleteEntity(EntitySvc, Request, Response); break; default: break; } return(Json(Response)); }
public static book_record BookRecById(string Id, AppUser AppUser) { Dictionary <string, object> Params = MixParamWithUnP(new Dictionary <string, object>() { { "id", Id }, { "Action", "bookRecById" } }, AppUser); Dictionary <string, object> RespParams = Request.PostReq(Transaction.URL, Params); if (RespParams["result"] != null && RespParams["result"].ToString() == "0") { Dictionary <string, object> DataMap = StringUtil.JSONStringToMap(RespParams["data"].ToString()); Dictionary <string, object> BookRecMap = StringUtil.JSONStringToMap(DataMap["book_record"].ToString()); return((book_record)ObjectUtil.FillObjectWithMap(new book_record(), BookRecMap)); } return(null); }
public ActionResult PositionSvc() { bool Access = UserValid() && IsAdmin(); WebResponse Response = new WebResponse(); if (!Access || !StringUtil.NotNullAndNotBlank(Request.Form["Action"])) { return(Json(Response)); } string Action = Request.Form["Action"].ToString(); PositionService EntitySvc = new PositionService(); switch (Action) { case "List": Response = MVCUtil.generateResponseList(EntitySvc, Request, LoggedUser, new string[] { "id", "name", "description", "section_id", "parent_position_id" }, typeof(position)); break; case "Form": Response = MVCUtil.generateResponseWithForm(typeof(position), EntitySvc, Request); break; case "Post": position position = (position)ObjectUtil.FillObjectWithMap(new position(), BaseService.ReqToDict(Request)); if (position != null) { Response = MVCUtil.UpdateEntity(EntitySvc, position, new string[] { "id", "name", "description", "section_id", "parent_position_id" }, Response); } break; case "Delete": Response = MVCUtil.DeleteEntity(EntitySvc, Request, Response); break; default: break; } return(Json(Response)); }
public static List <category> CategoryList(AppUser AppUser, int Offset, int Limit, Dictionary <string, object> Params) { List <category> categories = new List <category>(); List <Dictionary <string, object> > categoryListMap = UniversalObjList(AppUser, Offset, Limit, Params, "categoryList"); if (categoryListMap == null || categoryListMap.Count == 0) { return(categories); } foreach (Dictionary <string, object> categoryMap in categoryListMap) { if (categoryMap.Keys.Count == 1 && categoryMap.Keys.ElementAt(0).Equals("count")) { continue; } category category = (category)ObjectUtil.FillObjectWithMap(new category(), categoryMap); categories.Add(category); } return(categories); }
public static List <@class> ClassList(AppUser AppUser, int Offset, int Limit, Dictionary <string, object> Params) { List <@class> classs = new List <@class>(); List <Dictionary <string, object> > classListMap = UniversalObjList(AppUser, Offset, Limit, Params, "classList"); if (classListMap == null || classListMap.Count == 0) { return(classs); } foreach (Dictionary <string, object> classMap in classListMap) { if (classMap.Keys.Count == 1 && classMap.Keys.ElementAt(0).Equals("count")) { continue; } @class Class = (@class)ObjectUtil.FillObjectWithMap(new @class(), classMap); classs.Add(Class); } return(classs); }
public static List <author> AuthorList(AppUser AppUser, int Offset, int Limit, Dictionary <string, object> Params) { List <author> authors = new List <author>(); List <Dictionary <string, object> > authorListMap = UniversalObjList(AppUser, Offset, Limit, Params, "authorList"); if (authorListMap == null || authorListMap.Count == 0) { return(authors); } foreach (Dictionary <string, object> authorMap in authorListMap) { if (authorMap.Keys.Count == 1 && authorMap.Keys.ElementAt(0).Equals("count")) { continue; } author author = (author)ObjectUtil.FillObjectWithMap(new author(), authorMap); authors.Add(author); } return(authors); }