public IHttpActionResult Get(int id) { DreamService dreamService = CreateDreamService(); var dream = dreamService.GetDreamById(id); return(Ok(dream)); }
private DreamService CreateDreamService() { var userId = Guid.Parse(User.Identity.GetUserId()); var dreamService = new DreamService(userId); return(dreamService); }
public ActionResult DreamView(DreamGridDisplayModel dreamModel) { var _service = new DreamService(); _service.DreamFormUpdate(dreamModel); return(View(dreamModel)); }
public IHttpActionResult Get() { DreamService dreamService = CreateDreamService(); var dreams = dreamService.GetDreams(); return(Ok(dreams)); }
public JsonResult DreamFormBind(String id) { var _service = new DreamService(); var modelDataToReturn = _service.DreamFormBind(id); return(Json(modelDataToReturn, JsonRequestBehavior.AllowGet)); }
public JsonResult Delete(DreamModel model) { try { #region " [ Declaration ] " DreamService _service = new DreamService(); #endregion #region " [ Main process ] " model.CreateBy = UserID; model.DeleteBy = UserID; model.DeleteDate = DateTime.Now; #endregion //Call to service return(this.Json(_service.Delete(model), JsonRequestBehavior.AllowGet)); } catch (ServiceException serviceEx) { throw serviceEx; } catch (DataAccessException accessEx) { throw accessEx; } catch (Exception ex) { throw new ControllerException(FILE_NAME, "Delete", UserID, ex); } }
public ActionResult Edit(string id) { try { #region " [ Declaration ] " DreamService _service = new DreamService(); // ViewBag.id = id; #endregion // Call to service DreamModel model = _service.GetItemByID(new DreamModel() { ID = new Guid(id), CreateBy = UserID, Insert = false }); return(View(model)); } catch (ServiceException serviceEx) { throw serviceEx; } catch (DataAccessException accessEx) { throw accessEx; } catch (Exception ex) { throw new ControllerException(FILE_NAME, "Edit", UserID, ex); } }
private static void PrintBlueprint(string path, Assembly assembly) { foreach (Type type in assembly.GetTypes()) { object[] dsa = type.GetCustomAttributes(typeof(DreamServiceAttribute), false); if (!ArrayUtil.IsNullOrEmpty(dsa)) { XDoc blueprint = DreamService.CreateServiceBlueprint(type); foreach (XDoc sid in blueprint["sid"]) { SaveBlueprint(path, sid.AsUri, blueprint); } } } }
private static void PublishBlueprint(XUri uri, String login, String password, Assembly assembly, string service) { // retrieve the authentication cookie List <DreamCookie> cookies = null; Plug p = Plug.New(uri).AtPath("users/authenticate").WithCredentials(login, password); DreamMessage msg = DreamMessage.Ok(); msg = p.Get(msg, new Result <DreamMessage>()).Wait(); if (DreamStatus.Ok == msg.Status) { cookies = msg.Cookies; } else { throw new Exception("An error occurred during user authentication: " + msg.Status); } // extract all blueprints from the specified assembly and publish it to the wiki foreach (Type type in assembly.GetTypes()) { if (!string.IsNullOrEmpty(service) && !service.EqualsInvariantIgnoreCase(type.ToString())) { continue; } object[] dsa = type.GetCustomAttributes(typeof(DreamServiceAttribute), false); if (!ArrayUtil.IsNullOrEmpty(dsa)) { XDoc blueprint = DreamService.CreateServiceBlueprint(type); string info = blueprint["info"].Contents; string destination; try { destination = new XUri(info).Path.Trim('/'); if (string.IsNullOrEmpty(destination)) { throw new Exception(); } } catch { Console.WriteLine("Warning: Cannot pusblish service '{0}' because it does not have a valid Info Uri: {1}", type, info); continue; } PublishService(uri, login, password, cookies, destination, blueprint); foreach (XDoc feature in blueprint["//feature"]) { PublishFeature(uri, login, password, cookies, destination, feature); } } } }
public ActionResult DreamSubmit(DreamGridDisplayModel dreamModel) { var _service = new DreamService(); var dreamTable = new tbDream(); ProfileService profileService = new ProfileService(); dreamTable.EMPID = HttpContext.User.Identity.Name ?? string.Empty; dreamTable.EMPNAME = profileService.getEmpName(HttpContext.User.Identity.Name) == null ? String.Empty : profileService.getEmpName(HttpContext.User.Identity.Name); //dreamTable.LOCATION = profileService.getPhone(empID) == null ? String.Empty : profileService.getPhone(empID); dreamTable.LOCATION = profileService.getLocation(HttpContext.User.Identity.Name) == null ? String.Empty : profileService.getLocation(HttpContext.User.Identity.Name); dreamTable.DTITLE = dreamModel.DreamTitle ?? string.Empty; dreamTable.DDESCRIPTION = dreamModel.DreamDescription ?? string.Empty; dreamTable.SUBMITTEDDATE = DateTime.Now; dreamTable.STATUSID = 1; _service.DreamFormSubmit(dreamTable); return(View()); }
public JsonResult Index(CustomDataTableRequestHelper requestData) { try { #region " [ Declaration ] " DreamService _service = new DreamService(); #endregion #region " [ Main processing ] " // Process sorting column requestData = requestData.SetOrderingColumnName(); #endregion //Call to service Dictionary <string, object> _return = _service.List(requestData, UserID); if ((ResponseStatusCodeHelper)_return[DatatableCommonSetting.Response.STATUS] == ResponseStatusCodeHelper.OK) { DataTableResponse <DreamModel> itemResponse = _return[DatatableCommonSetting.Response.DATA] as DataTableResponse <DreamModel>; return(this.Json(itemResponse, JsonRequestBehavior.AllowGet)); } // return(this.Json(new DataTableResponse <DreamModel>(), JsonRequestBehavior.AllowGet)); } catch (ServiceException serviceEx) { throw serviceEx; } catch (DataAccessException accessEx) { throw accessEx; } catch (Exception ex) { throw new ControllerException(FILE_NAME, "Index", UserID, ex); } }
public JsonResult Edit(DreamModel model) { try { #region " [ Declaration ] " DreamService _service = new DreamService(); #endregion #region " [ Main processing ] " if (model.FinishTimeString.Length > 0) { string[] tmp = model.FinishTimeString.Split('/'); model.FinishTime = new DateTime(int.Parse(tmp[2]), int.Parse(tmp[1]), int.Parse(tmp[0])); } model.CreateBy = UserID; model.UpdateBy = UserID; model.CreateDate = DateTime.Now; model.UpdateDate = DateTime.Now; #endregion // Call to service return(this.Json(_service.Save(model), JsonRequestBehavior.AllowGet)); } catch (ServiceException serviceEx) { throw serviceEx; } catch (DataAccessException accessEx) { throw accessEx; } catch (Exception ex) { throw new ControllerException(FILE_NAME, "Edit", UserID, ex); } }
public JsonResult DreamGridData() { int page = int.Parse(Request.QueryString["page"]); int rows = int.Parse(Request.QueryString["rows"]); var _service = new DreamService(); var gridData = _service.DreamGridDisplay(); var jsonData = new { total = gridData.Count / 10, //todo: calculate page = page, records = gridData.Count, rows = (from data in gridData select new { id = data.DreamId, cell = new string[] { data.DreamId.ToString(), data.DreamTitle ?? "", data.DreamDescription ?? "", data.EmpId ?? "", data.EmpName ?? "", data.Location ?? "", data.SubmittedDate ?? string.Empty, getStatus(int.Parse(data.Status)) ?? "", data.ContactPerson ?? "" } }).Skip((page) * rows - rows).Take(rows).ToArray() }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); }