Exemplo n.º 1
0
        public void TestPurchaserMethods()
        {
            var query = ClientRepository.GetPurchasers();

            Assert.IsTrue(query.Count() > 0);

            var purch = ClientRepository.AddOrUpdatePurchaser(1301, true);

            Assert.AreEqual("Getty, James", purch.DisplayName);

            Assert.IsTrue(ClientRepository.IsPurchaser(purch.ClientID));

            var p = ClientRepository.GetPurchaser(1301);

            Assert.AreEqual("Getty, James", p.DisplayName);

            ClientRepository.DeletePurchaser(p.PurchaserID);

            Assert.IsFalse(ClientRepository.IsPurchaser(p.ClientID));

            //clean up
            var entity = DataSession.Single <Ordering.Purchaser>(p.PurchaserID);

            DataSession.Delete(entity);
        }
Exemplo n.º 2
0
        public bool Delete(int orgId, int addressId, string addressType)
        {
            var entity = DataSession.Single <Address>(addressId);

            if (entity != null)
            {
                DataSession.Delete(new[] { entity });
                OrgAddressType type = (OrgAddressType)Enum.Parse(typeof(OrgAddressType), addressType);
                Org            org  = DataSession.Single <Org>(orgId);
                switch (type)
                {
                case OrgAddressType.Billing:
                    org.DefBillAddressID = 0;
                    break;

                case OrgAddressType.Client:
                    org.DefClientAddressID = 0;
                    break;

                case OrgAddressType.Shipping:
                    org.DefShipAddressID = 0;
                    break;
                }

                DataSession.SaveOrUpdate(org);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        public DepartmentModel[] Delete(int id)
        {
            var entity = DataSession.Single <Department>(id);
            var orgId  = entity.Org.OrgID;

            DataSession.Delete(new Department[] { entity });
            return(Get(orgId));
        }
        public ActionResult DeleteConfirmed(string id)
        {
            var blog = DataSession.Load <Blog>(("blogs/" + id));

            DataSession.Delete(blog);
            DataSession.SaveChanges();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 5
0
        public ActionResult Ajax(int id)
        {
            var gs = DataSession.Single <LNF.Impl.Repository.Data.GlobalSettings>(id);

            if (gs != null)
            {
                DataSession.Delete(gs);
            }

            var items = DataSession.Query <LNF.Impl.Repository.Data.GlobalSettings>();

            return(Json(items, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
        public bool DeleteDraft(int poid)
        {
            var po = Require <Ordering.PurchaseOrder>(x => x.POID, poid);

            if (po.Status.StatusID == (int)OrderStatus.Draft)
            {
                Tracking.Track(TrackingCheckpoints.Deleted, po.CreateModel <IPurchaseOrder>(), Context.CurrentUser.ClientID);
                DataSession.Delete(po.Details);
                DataSession.Delete(po);
                return(true);
            }

            return(false);
        }
Exemplo n.º 7
0
        public bool Delete([FromBody] AddressModel model, int id)
        {
            Address addr = DataSession.Single <Address>(model.AddressID);

            ClientOrg co = DataSession.Single <ClientOrg>(id);

            if (addr != null && co != null)
            {
                DataSession.Delete(addr);
                co.ClientAddressID = 0;
                DataSession.SaveOrUpdate(co);

                return(true);
            }

            return(false);
        }
Exemplo n.º 8
0
        protected void Delete_Command(object sender, CommandEventArgs e)
        {
            var clientId  = Convert.ToInt32(e.CommandArgument);
            var authLevel = (ClientAuthLevel)Enum.Parse(typeof(ClientAuthLevel), e.CommandName);
            var cc        = CurrentClients.FirstOrDefault(x => x.ClientID == clientId);

            if (cc != null)
            {
                var rc = DataSession.Single <ResourceClient>(cc.ResourceClientID);

                DataSession.Delete(rc);
                ClearResourceClientsCache();

                CurrentClients.Remove(cc);
            }

            Fill(authLevel);
            FillClients();
        }
Exemplo n.º 9
0
        public ActionResult DeleteConfirmed(string id)
        {
            try
            {
                var post = DataSession.Load <Post>("posts/" + id);
                DataSession.Delete(post);
                DataSession.SaveChanges();

                TempData["success"] = "Inlägget är nu borttagen";
                UpdateModel("Index");

                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                TempData["error"] = "Borttagning av posten misslyckades!";
                RedirectToAction("Delete", new { id });
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 10
0
        public void Delete(int podid)
        {
            var pod = Require <Ordering.PurchaseOrderDetail>(x => x.PODID, podid);

            DataSession.Delete(pod);
        }
Exemplo n.º 11
0
        public ActionResult Update(int orgId)
        {
            // save all changes
            if (Session["AccountEdit"] != null)
            {
                var acctEdit = (AccountEdit)Session["AccountEdit"];

                Account acct;
                bool    insert = false;

                if (acctEdit.AccountID > 0)
                {
                    acct = DataSession.Single <Account>(acctEdit.AccountID);
                }
                else
                {
                    acct = new Account {
                        Org = DataSession.Single <Org>(orgId)
                    };
                    insert = true;
                }

                if (acct != null)
                {
                    acct.Name             = acctEdit.AccountName;
                    acct.Number           = AccountEditUtility.GetAccountNumber(acctEdit);
                    acct.ShortCode        = AccountEditUtility.GetShortCode(acctEdit);
                    acct.FundingSourceID  = acctEdit.FundingSourceID;
                    acct.TechnicalFieldID = acctEdit.TechnicalFieldID;
                    acct.SpecialTopicID   = acctEdit.SpecialTopicID;
                    acct.AccountType      = DataSession.Single <AccountType>(acctEdit.AccountTypeID);
                    acct.InvoiceNumber    = acctEdit.InvoiceNumber;
                    acct.InvoiceLine1     = acctEdit.InvoiceLine1;
                    acct.InvoiceLine2     = acctEdit.InvoiceLine2;
                    acct.PoEndDate        = acctEdit.PoEndDate;
                    acct.PoInitialFunds   = acctEdit.PoInitialFunds;

                    // handle addresses
                    foreach (var kvp in acctEdit.Addresses)
                    {
                        if (kvp.Value != null)
                        {
                            Address addr;
                            bool    insertAddr = false;

                            if (kvp.Value.AddressID == 0)
                            {
                                addr       = new Address();
                                insertAddr = true;
                            }
                            else
                            {
                                addr = DataSession.Single <Address>(kvp.Value.AddressID);
                            }

                            addr.InternalAddress = kvp.Value.Attention;
                            addr.StrAddress1     = kvp.Value.AddressLine1;
                            addr.StrAddress2     = kvp.Value.AddressLine2;
                            addr.City            = kvp.Value.City;
                            addr.State           = kvp.Value.State;
                            addr.Zip             = kvp.Value.Zip;
                            addr.Country         = kvp.Value.Country;

                            if (insertAddr)
                            {
                                DataSession.Insert(addr);
                            }

                            if (kvp.Key == "billing")
                            {
                                acct.BillAddressID = addr.AddressID;
                            }

                            if (kvp.Key == "shipping")
                            {
                                acct.ShipAddressID = addr.AddressID;
                            }
                        }
                        else
                        {
                            if (kvp.Key == "billing")
                            {
                                if (acct.BillAddressID > 0)
                                {
                                    DataSession.Delete(DataSession.Single <Address>(acct.BillAddressID));
                                }
                                acct.BillAddressID = 0;
                            }
                            if (kvp.Key == "shipping")
                            {
                                if (acct.ShipAddressID > 0)
                                {
                                    DataSession.Delete(DataSession.Single <Address>(acct.ShipAddressID));
                                }
                                acct.ShipAddressID = 0;
                            }
                        }
                    }

                    if (insert)
                    {
                        DataSession.Insert(acct);
                        Provider.Data.ActiveLog.Enable(acct);
                    }

                    // handle managers
                    var currentManagers = AccountEditUtility.GetManagerEdits(acct.AccountID).ToList();

                    foreach (var mgr in acctEdit.Managers)
                    {
                        if (!currentManagers.Any(x => x.ClientOrgID == mgr.ClientOrgID))
                        {
                            // adding a new manager

                            // check for an existing ClientAccount to make a manager and reactivate if needed
                            ClientAccount ca;

                            ca = DataSession.Query <ClientAccount>().FirstOrDefault(x => x.ClientOrg.ClientOrgID == mgr.ClientOrgID && x.Account == acct);

                            if (ca != null)
                            {
                                ca.Manager = true;
                                if (!ca.Active)
                                {
                                    Provider.Data.ActiveLog.Enable(ca);
                                }
                            }
                            else
                            {
                                ca = new ClientAccount()
                                {
                                    ClientOrg = DataSession.Single <ClientOrg>(mgr.ClientOrgID),
                                    Account   = acct,
                                    Manager   = true,
                                    IsDefault = false
                                };

                                DataSession.Insert(ca);

                                Provider.Data.ActiveLog.Enable(ca);
                            }

                            currentManagers.Add(new AccountManagerEdit()
                            {
                                ClientOrgID = ca.ClientOrg.ClientOrgID,
                                FName       = ca.ClientOrg.Client.FName,
                                LName       = ca.ClientOrg.Client.LName
                            });
                        }
                    }

                    // now check for any deleted managers
                    foreach (var mgr in currentManagers.ToArray())
                    {
                        if (!acctEdit.Managers.Any(x => x.ClientOrgID == mgr.ClientOrgID))
                        {
                            // a current manager was deleted

                            ClientAccount ca = DataSession.Query <ClientAccount>()
                                               .FirstOrDefault(x => x.ClientOrg.ClientOrgID == mgr.ClientOrgID && x.Account == acct);

                            if (ca != null)
                            {
                                RemoveManager(ca);
                                currentManagers.Remove(mgr);
                            }
                        }
                    }
                }

                Session.Remove("AccountEdit");
            }

            return(RedirectToAction("Index", new { orgId }));
        }
Exemplo n.º 12
0
        public void Delete(int departmentId)
        {
            var entity = DataSession.Single <Department>(departmentId);

            DataSession.Delete(new Department[] { entity });
        }