Ejemplo n.º 1
0
        private Invoice UpdateInvoiceStatusInDb(int invoiceid, InvoiceStatus status)
        {
            var invoice = GetByIDFromDb(invoiceid);

            if (invoice == null)
            {
                _logger.Error("Invoice not found");

                return(null);
            }
            _crmSecurity.DemandAccessTo(invoice);

            if (!invoiceStatusMap.Contains(new KeyValuePair <InvoiceStatus, InvoiceStatus>(invoice.Status, status)))
            {
                _logger.ErrorFormat("Status for invoice with ID={0} can't be changed. Return without changes", invoiceid);

                return(invoice);
            }

            var itemToUpdate = Query(CrmDbContext.Invoices).FirstOrDefault(x => x.Id == invoiceid);

            itemToUpdate.Status        = status;
            itemToUpdate.LastModifedOn = DateTime.UtcNow;
            itemToUpdate.LastModifedBy = _securityContext.CurrentAccount.ID;

            CrmDbContext.Update(itemToUpdate);

            CrmDbContext.SaveChanges();

            invoice.Status = status;

            return(invoice);
        }
Ejemplo n.º 2
0
        public RelationshipEvent GetByID(int id)
        {
            var dbEntity = CrmDbContext.RelationshipEvent.Find(id);

            if (dbEntity.TenantId != TenantID)
            {
                return(null);
            }

            var entity = _mapper.Map <DbRelationshipEvent, RelationshipEvent>(dbEntity);

            _crmSecurity.DemandAccessTo(entity);

            return(entity);
        }
Ejemplo n.º 3
0
        public Cases GetByID(int id)
        {
            var dbEntity = CrmDbContext.Cases.Find(id);

            if (dbEntity.TenantId != TenantID)
            {
                return(null);
            }

            var entity = _mapper.Map <Cases>(dbEntity);

            _crmSecurity.DemandAccessTo(entity);

            return(_mapper.Map <Cases>(dbEntity));
        }