// POST api/<controller> public HttpResponseMessage Post([FromBody] JObject value) { UserDomainService UserDomainService = new Ewav.Web.Services.UserDomainService(); CanvasDomainService CanvasDomainService = new Ewav.Web.Services.CanvasDomainService.CanvasDomainService(); ControllerCommon Common = new Controllers.ControllerCommon(); DatatableBag dtb = null; UserDTO possibleUser = new UserDTO(); possibleUser.UserName = value["id"].ToString(); var pwd = value["password"].ToString(); string KeyForUserPasswordSalt = System.Configuration.ConfigurationManager.AppSettings["KeyForUserPasswordSalt"]; Ewav.PasswordHasher ph = new Ewav.PasswordHasher(KeyForUserPasswordSalt); string salt = ph.CreateSalt(possibleUser.UserName); possibleUser.PasswordHash = ph.HashPassword(salt, pwd); UserDTO returnedUser = UserDomainService.GetUserForAuthentication(possibleUser); if (returnedUser.UserID != -1) { UserDTO LoadedUser = UserDomainService.LoadUser(returnedUser.UserName); dtb = CanvasDomainService.LoadCanvasListForUser(LoadedUser.UserID); } List <CanvasDto> CanvasList = new List <CanvasDto>(); for (int i = 0; i < dtb.RecordList.Count; i++) { CanvasList.Add( new CanvasDto() { CanvasId = Convert.ToInt32(Common.GetValueAtRow(dtb, "CanvasID", dtb.RecordList[i])), CanvasName = Common.GetValueAtRow(dtb, "CanvasName", dtb.RecordList[i]), UserId = Convert.ToInt32(Common.GetValueAtRow(dtb, "UserID", dtb.RecordList[i])), CanvasDescription = Common.GetValueAtRow(dtb, "CanvasDescription", dtb.RecordList[i]), CreatedDate = Convert.ToDateTime(Common.GetValueAtRow(dtb, "CreatedDate", dtb.RecordList[i])), ModifiedDate = Convert.ToDateTime(Common.GetValueAtRow(dtb, "ModifiedDate", dtb.RecordList[i])), DatasourceID = Convert.ToInt32(Common.GetValueAtRow(dtb, "DatasourceID", dtb.RecordList[i])), Status = Common.GetValueAtRow(dtb, "Status", dtb.RecordList[i]), Datasource = Common.GetValueAtRow(dtb, "DatasourceName", dtb.RecordList[i]) //XmlData = new System.Xml.Linq.XElement() }); } HttpResponseMessage ReturnedObj = new HttpResponseMessage() { Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(CanvasList)) }; ReturnedObj.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); return(ReturnedObj); }
/// <summary> /// This post method returns all the canvases for a user in a given datasource. /// </summary> /// <param name="value"></param> /// <returns></returns> public HttpResponseMessage Post([FromBody] JObject value) { UserDomainService UserDomainService = new Ewav.Web.Services.UserDomainService(); AdminDatasourcesDomainService AdminDatasourcesDomainService = new AdminDatasourcesDomainService(); CanvasDomainService CanvasDomainService = new Ewav.Web.Services.CanvasDomainService.CanvasDomainService(); ControllerCommon Common = new Controllers.ControllerCommon(); DatatableBag dtb = null; UserDTO possibleUser = new UserDTO(); possibleUser.UserName = value["id"].ToString(); UserDTO returnedUser = UserDomainService.GetUserForAuthentication(possibleUser); if (returnedUser.UserID != -1) { returnedUser = UserDomainService.LoadUser(returnedUser.UserName); //dtb = CanvasDomainService.LoadCanvasListForUser(LoadedUser.UserID); } //Guid DSGuid, UserGuid; //Guid.TryParse(value["datasourceid"].ToString(), out DSGuid); //Guid.TryParse(value["userid"].ToString(), out UserGuid); dtb = CanvasDomainService.ReadCanvasListForLite(value["datasourceid"].ToString(), returnedUser.UserID); //int ewavdatasourceid = AdminDatasourcesDomainService.ReadEwavDatasource(DSGuid); List <CanvasDto> CanvasList = new List <CanvasDto>(); Guid TempCanvasGuid; for (int i = 0; i < dtb.RecordList.Count; i++) { Guid.TryParse(Common.GetValueAtRow(dtb, "CanvasGUID", dtb.RecordList[i]), out TempCanvasGuid); CanvasList.Add( new CanvasDto() { CanvasId = Convert.ToInt32(Common.GetValueAtRow(dtb, "CanvasID", dtb.RecordList[i])), CanvasName = Common.GetValueAtRow(dtb, "CanvasName", dtb.RecordList[i]), UserId = Convert.ToInt32(Common.GetValueAtRow(dtb, "UserID", dtb.RecordList[i])), CanvasDescription = Common.GetValueAtRow(dtb, "CanvasDescription", dtb.RecordList[i]), CreatedDate = Convert.ToDateTime(Common.GetValueAtRow(dtb, "CreatedDate", dtb.RecordList[i])), ModifiedDate = Convert.ToDateTime(Common.GetValueAtRow(dtb, "ModifiedDate", dtb.RecordList[i])), DatasourceID = Convert.ToInt32(Common.GetValueAtRow(dtb, "DatasourceID", dtb.RecordList[i])), Status = Common.GetValueAtRow(dtb, "Status", dtb.RecordList[i]), Datasource = Common.GetValueAtRow(dtb, "DatasourceName", dtb.RecordList[i]), CanvasGUID = TempCanvasGuid //XmlData = new System.Xml.Linq.XElement() }); } // CanvasList = CanvasList.Where(canvas => canvas.DatasourceID == ewavdatasourceid).ToList(); HttpResponseMessage ReturnedObj = new HttpResponseMessage() { Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(CanvasList)) }; ReturnedObj.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); return(ReturnedObj); }