Beispiel #1
0
        public bool EditStatus(int statusId, ApplicationStatus status)
        {
            var timestamp = _context.ApplicationStatus
                            .AsNoTracking()
                            .SingleOrDefault(s => s.Id == statusId)
                            .Timestamp;

            if (status.Timestamp != timestamp)
            {
                return(false);
            }

            _context.Entry(status).State = EntityState.Modified;

            try
            {
                _context.SaveChanges();
            }
            catch (Exception e)
            {
                //TODO: Log
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        public bool EditCompany(int companyId, Company company)
        {
            if (companyId != company.Id || string.IsNullOrWhiteSpace(company.Name))
            {
                return(false);
            }

            _context.Entry(company).State = EntityState.Modified;

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                // TODO: Log
                return(false);
            }

            return(true);
        }
Beispiel #3
0
        public bool EditApplication(int appId, Application app)
        {
            if (appId != app.Id ||
                app.CompanyId == null)
            {
                return(false);
            }

            _context.Entry(app).State = EntityState.Modified;

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(false);
            }

            return(true);
        }
Beispiel #4
0
        public bool EditContact(int contactId, Contact contact)
        {
            if (contactId != contact.Id ||
                (string.IsNullOrWhiteSpace(contact.FirstName) &&
                 string.IsNullOrWhiteSpace(contact.LastName)))
            {
                return(false);
            }

            _context.Entry(contact).State = EntityState.Modified;

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                // TODO: Log
                return(false);
            }

            return(true);
        }