示例#1
0
        public RQItem Post(string dbname, [FromBody] RQItem newRQItem)
        {
            if (ModelState.IsValid)
            {
                RQItem      rqitem = null;
                RQItemModel model  = new RQItemModel(true);

                rqitem = model.Add(newRQItem);
                model.Update();
                CacheManager.Clear();
                return(Get("rqitems", rqitem.DocNo, "rqi", "edititem", ""));
            }
            else
            {
                throw new HttpResponseException(JsonErrorResponse.InvalidData());
            }
        }
示例#2
0
        public ActionResult UpdateItem(string verb, string rqitemId, string serviceId, RQItem changeRQItem)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            if ((rqitemId != null) && (rqitemId != ""))
            {
                if ((verb.ToLower() == "cancel") || (verb == RQResources.Views.Shared.SharedStrings.cancel))
                {
                    return(this.RedirectToRoute("RQItemList", new { dbname = "rqitems" }));
                }
                else if ((verb.ToLower() == "finalize") || (verb == RQResources.Views.Shared.SharedStrings.finish))
                {
                    return(this.RedirectToRoute("RQItemList", new { dbname = "rqitems" }));
                }
                else
                {
                    if (MvcRQ.Helpers.AccessRightsResolver.HasAddAccess())
                    {
                        RQItemModel model  = null;
                        RQItem      rqitem = null;
                        try
                        {
                            model  = modelRepository.GetModel("$access$" + rqitemId, UserState.States.EditState, true);
                            rqitem = model.RQItems.FirstOrDefault(p => p.DocNo == rqitemId);
                            if ((verb.ToLower() == "update") || (verb == RQResources.Views.Shared.SharedStrings.update))
                            {
                                rqitem.Change(changeRQItem);
                            }
                            else if ((verb.ToLower() == "new") || (verb == RQResources.Views.Shared.SharedStrings.add))
                            {
                                rqitem = model.Add(changeRQItem);
                            }
                            else if ((verb.ToLower() == "delete") || (verb == RQResources.Views.Shared.SharedStrings.delete))
                            {
                            }   // not yet implemented
                            model.Update();
                        }
                        catch (Exception ex)
                        {
                            string    message = "Update operation failed. ";
                            Exception iex     = ex;

                            while (iex != null)
                            {
                                if (!string.IsNullOrEmpty(iex.Message))
                                {
                                    message += "\n - " + iex.Message;
                                }
                                iex = iex.InnerException;
                            }
                            throw new Exception(message);
                        };
                        CacheManager.Clear();
                        ViewBag.EditButton2 = RQResources.Views.Shared.SharedStrings.finish;
                        if (AccessRightsResolver.HasAddAccess())
                        {
                            ViewBag.EditButton3     = RQResources.Views.Shared.SharedStrings.copy;
                            ViewBag.EditButton3Link = "/RQItems/" + rqitem.DocNo + "?verb=copy";
                            ViewBag.EditButton4     = RQResources.Views.Shared.SharedStrings.add;
                            ViewBag.EditButton4Link = "/RQItems?verb=new";
                        }
                        return(RQItemRecord((verb == "") ? verb : "edititem", rqitem.DocNo, serviceId));
                    }
                    else
                    {
                        throw new System.AccessViolationException(RQResources.Views.Shared.SharedStrings.err_not_authorized);
                    }
                }
            }
            throw new NotImplementedException("No item for update specified.");
        }
示例#3
0
        public ActionResult RQItemList(string verb, string queryString, RQItem newRQItem)
        {
            if ((!string.IsNullOrEmpty(verb)) && ((verb.ToLower() == "new") || (verb == RQResources.Views.Shared.SharedStrings.add)))
            {
                if (MvcRQ.Helpers.AccessRightsResolver.HasAddAccess())
                {
                    RQItem rqitem = null;

                    if (ModelState.IsValid)
                    {
                        try
                        {
                            RQItemModel model = new RQItemModel(true);

                            rqitem = model.Add(newRQItem);
                            model.Update();
                        }
                        catch (Exception ex)
                        {
                            string    message = "Add operation failed. ";
                            Exception iex     = ex;

                            while (iex != null)
                            {
                                if (!string.IsNullOrEmpty(iex.Message))
                                {
                                    message += "\n - " + iex.Message;
                                }
                                iex = iex.InnerException;
                            }
                            throw new Exception(message);
                        }
                        CacheManager.Clear();
                        if (bClientEditing)
                        {
                        }
                        else
                        {
                            ViewBag.EditButton2     = RQResources.Views.Shared.SharedStrings.finish;
                            ViewBag.EditButton3     = RQResources.Views.Shared.SharedStrings.copy;
                            ViewBag.EditButton3Link = "/RQItems/" + rqitem.DocNo + "?verb=copy";
                            ViewBag.EditButton4     = RQResources.Views.Shared.SharedStrings.add;
                            ViewBag.EditButton4Link = "/RQItems?verb=new";
                        }
                        return(RQItemRecord((verb == "") ? verb : "edititem", rqitem.DocNo, null));
                    }
                    else
                    {
                        if (bClientEditing)
                        {
                            ViewBag.RQItemId = "";
                            return(View("ClientEditor"));
                        }
                        else
                        {
                            ViewBag.EditButton1 = RQResources.Views.Shared.SharedStrings.add;
                            ViewBag.EditButton2 = RQResources.Views.Shared.SharedStrings.cancel;
                            return(View("EditRQItem", newRQItem));
                        }
                    }
                }
                else
                {
                    throw new AccessViolationException("Not authorized for this function!");
                }
            }
            else if ((!string.IsNullOrEmpty(verb)) && ((verb.ToLower() == "cancel") || (verb == RQResources.Views.Shared.SharedStrings.cancel)))
            {
                return(this.RedirectToRoute("RQItemList", new { dbname = "rqitems" }));
            }
            else
            {
                ViewBag.HasAddPermit  = MvcRQ.Helpers.AccessRightsResolver.HasAddAccess(); // Enable the add new button if user is allowed to add RQItems ti the database.
                ViewBag.GetRQItemVerb = "QueryItem";                                       // Tell GetRQItem() in ResultViewer the appropiate verb for saving the user state.
                return(View("Index"));
            }
        }
示例#4
0
        public ActionResult RQItemList(string verb, string queryString, RQItem newRQItem)
        {
            if ((!string.IsNullOrEmpty(verb)) && ((verb.ToLower() == "new") || (verb == RQResources.Views.Shared.SharedStrings.add)))
            {
                if (MvcRQ.Helpers.AccessRightsResolver.HasAddAccess())
                {
                    RQItem rqitem = null;

                    if (ModelState.IsValid)
                    {
                        try
                        {
                            RQItemModel model = new RQItemModel(true);

                            rqitem = model.Add(newRQItem);
                            model.Update();
                        }
                        catch (Exception ex)
                        {
                            string message = "Add operation failed. ";
                            Exception iex = ex;

                            while (iex != null)
                            {
                                if (!string.IsNullOrEmpty(iex.Message))
                                    message += "\n - " + iex.Message;
                                iex = iex.InnerException;
                            }
                            throw new Exception(message);
                        }
                        CacheManager.Clear();
                        if (bClientEditing)
                        {
                        }
                        else
                        {
                            ViewBag.EditButton2 = RQResources.Views.Shared.SharedStrings.finish;
                            ViewBag.EditButton3 = RQResources.Views.Shared.SharedStrings.copy;
                            ViewBag.EditButton3Link = "/RQItems/" + rqitem.DocNo + "?verb=copy";
                            ViewBag.EditButton4 = RQResources.Views.Shared.SharedStrings.add;
                            ViewBag.EditButton4Link = "/RQItems?verb=new";
                        }
                        return RQItemRecord((verb == "") ? verb : "edititem", rqitem.DocNo, null);
                    }
                    else
                    {
                        if (bClientEditing)
                        {
                            ViewBag.RQItemId = "";
                            return View("ClientEditor");
                        }
                        else
                        {
                            ViewBag.EditButton1 = RQResources.Views.Shared.SharedStrings.add;
                            ViewBag.EditButton2 = RQResources.Views.Shared.SharedStrings.cancel;
                            return View("EditRQItem", newRQItem);
                        }
                    }
                }
                else
                    throw new AccessViolationException("Not authorized for this function!");
            }
            else if ((!string.IsNullOrEmpty(verb)) && ((verb.ToLower() == "cancel") || (verb == RQResources.Views.Shared.SharedStrings.cancel)))
                return this.RedirectToRoute("RQItemList", new { dbname = "rqitems" });
            else
            {
                ViewBag.HasAddPermit = MvcRQ.Helpers.AccessRightsResolver.HasAddAccess(); // Enable the add new button if user is allowed to add RQItems ti the database.
                ViewBag.GetRQItemVerb = "QueryItem"; // Tell GetRQItem() in ResultViewer the appropiate verb for saving the user state.
                return View("Index");
            }
        }
示例#5
0
        public RQItem Post(string dbname, [FromBody]RQItem newRQItem)
        {
            if (ModelState.IsValid)
            {
                RQItem rqitem = null;
                RQItemModel model = new RQItemModel(true);

                rqitem = model.Add(newRQItem);
                model.Update();
                CacheManager.Clear();
                return Get("rqitems",rqitem.DocNo, "rqi", "edititem", "");
            }
            else
                throw new HttpResponseException(JsonErrorResponse.InvalidData());
        }