Beispiel #1
0
        public ActionResult Delete(long id)
        {
            // is order in use
            var order = repository.GetOrder(subdomainid.Value, id);

            if (order == null)
            {
                return(SendJsonErrorResponse("Order not found"));
            }

            var transaction = new Transaction(order, repository, sessionid.Value);
            var status      = transaction.GetOrderStatus();

            if (status != OrderStatus.DRAFT && status != OrderStatus.SENT)
            {
                return(SendJsonErrorResponse("Unable to delete. Order has already been viewed."));
            }

            try
            {
#if LUCENE
                var indexer = new LuceneWorker(db, MASTERdomain.ToIdName());
                indexer.DeleteFromIndex(LuceneIndexType.TRANSACTION, id);
#endif
                repository.UpdateCounters(subdomainid.Value, -1, CounterType.ORDERS_SENT);

                transaction.DeleteOrder();
            }
            catch (Exception ex)
            {
                return(SendJsonErrorResponse(ex));
            }

            return(Json(id.ToJsonOKData()));
        }
        public ActionResult Delete(string id)
        {
            var contactids = id.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse);
            var successIDs = new List <long>();

            foreach (var contactid in contactids)
            {
                if (repository.IsContactInUse(contactid))
                {
                    continue;
                }
#if LUCENE
                var indexer = new LuceneWorker(db, MASTERdomain.ToIdName());
                indexer.DeleteFromIndex(LuceneIndexType.CONTACTS, contactid);
#endif
                // delete necessary data
                repository.DeleteUser(contactid, subdomainid.Value);
                successIDs.Add(contactid);
            }

            return(Json(successIDs.ToJsonOKData()));
        }