Exemple #1
0
        public vas_invoices CreateInvoice(int contractorID, aspnet_Users user, out string msg)
        {
            var res = new vas_invoices();

            msg = "";
            try
            {
                if (!_canManageInvoice(user))
                {
                    msg = "Нет прав для данной операции";
                    return(res = null);
                }

                res.number       = _getRandomString(8);
                res.date         = DateTime.Now;
                res.statusID     = 1;
                res.contractorID = contractorID;
                res.comment      = "Комментарий";
                res.code         = _getRandomString(8).ToLower();

                db.SaveInvoice(res);
            }
            catch (Exception ex)
            {
                _debug(ex, new { contractorID = contractorID, userName = user.UserName });
                res = null;
                msg = "Сбой при выполнеии операции";
            }
            return(res);
        }
Exemple #2
0
        private bool _canManageInvoice(aspnet_Users user, vas_invoices item = null)
        {
            var res = false;

            if ((user != null && user.UserName == "*****@*****.**") && (item == null || item is vas_invoices))
            {
                return(true);
            }
            return(res);
        }
Exemple #3
0
 public int SaveInvoice(vas_invoices item, bool withSave = true)
 {
     if (item.id == 0)
     {
         Db.vas_invoices.Add(item);
         if (withSave)
         {
             Save();
         }
     }
     else
     {
         Db.Entry(item).State = EntityState.Modified;
         if (withSave)
         {
             Save();
         }
     }
     return(item.id);
 }
Exemple #4
0
        public bool _logInvoiceStatusChange(vas_invoices item, string note = "")
        {
            var res = false;

            try
            {
                db.SaveInvoiceStatusLog(new vas_invoiceStatusesLog
                {
                    id        = 0,
                    created   = DateTime.Now,
                    statusID  = item.statusID,
                    invoiceID = item.id,
                    note      = note
                });
                res = true;
            }
            catch (Exception ex)
            {
                _debug(ex, new { invoiceID = item.id, statusID = item.statusID, note });
            }
            return(res);
        }
Exemple #5
0
        public vas_invoices GetInvoice(int id, aspnet_Users user, out string msg)
        {
            var res = new vas_invoices();

            msg = "";
            try
            {
                res = db.GetInvoice(id);
                if (!_canAccessToInvoice(user, res))
                {
                    msg = "Нет прав для данной операции";
                    return(res = null);
                }
            }
            catch (Exception ex)
            {
                _debug(ex, new { invoiceID = id, userName = user.UserName });
                res = null;
                msg = "Сбой при выполнеии операции";
            }

            return(res);
        }