public IList <MessageString> Validate(IUnitOfWork db)
        {
            var messages = new List <MessageString>();

            var order = db.Orders.GetByOrderIdAsDto(OrderNumber);

            if (!String.IsNullOrEmpty(TrackingNumber))
            {
                var           shipping = db.OrderShippingInfos.GetAll().FirstOrDefault(sh => sh.TrackingNumber == TrackingNumber);
                MailLabelInfo mail     = null;
                if (shipping == null)
                {
                    mail = db.MailLabelInfos.GetAll().FirstOrDefault(m => m.TrackingNumber == TrackingNumber);
                }

                if (shipping == null && mail == null)
                {
                    messages.Add(MessageString.From("TrackingNumber", "Tracking number not found"));
                }

                return(messages);
            }

            if (order == null)
            {
                messages.Add(MessageString.From("OrderNumber", "Order not found"));
            }

            return(messages);
        }
예제 #2
0
        //public void UnlockUser(IUnitOfWork db,
        //    long userId)
        //{
        //    var user = db.Users.GetById(userId);
        //    if (user != null)
        //    {
        //        user.IsLockedOut = false;
        //        user.PasswordFailuresSinceLastSuccess = 0;

        //        db.Commit();
        //    }
        //}

        public IList <MessageString> Delete(IUnitOfWork db,
                                            DateTime?when,
                                            long?by)
        {
            var results = new List <MessageString>();

            if (Id == by)
            {
                results.Add(MessageString.From("", "You can't delete yourself"));
                return(results);
            }

            if (Id.HasValue)
            {
                var user = db.Users.GetById(Id.Value);
                if (user != null)
                {
                    user.DeleteDate = when;
                    user.Deleted    = true;
                    db.Commit();
                }
            }

            return(results);
        }