public TableAdjustment EditQueue(LatticeData <PhoneInstallationQueue, PhoneInstallationQueueRow> latticeData, PhoneInstallationQueueRow queueRow)
        {
            PhoneInstallationQueue currentQueue = null;

            if (queueRow.Id == 0)
            {
                currentQueue = new PhoneInstallationQueue();
                _context.PhoneInstallationQueues.Add(currentQueue);
            }
            else
            {
                currentQueue = _context.PhoneInstallationQueues.FirstOrDefault(x => x.Id == queueRow.Id);
            }

            currentQueue.AtsUserId = queueRow.UserId;
            _context.SaveChanges();

            queueRow.Id = currentQueue.Id;

            queueRow.UserName = _context.AtsUsers
                                .Where(user => user.Id == queueRow.UserId)
                                .Select(user => user.Person.Name)
                                .FirstOrDefault();

            queueRow.UserSurname = _context.AtsUsers
                                   .Where(user => user.Id == queueRow.UserId)
                                   .Select(user => user.Person.Surname)
                                   .FirstOrDefault();

            return(latticeData.Adjust(x => x
                                      .Update(queueRow)
//                .Message(LatticeMessage.AtsUser("success", "Editing", "Person saved!"))
                                      ));
        }
Example #2
0
//        public TableAdjustment UpdateRow(LatticeData<Person, PersonRow> latticeData)
//        {
//            return latticeData.Adjust(x => x.Build());
//        }

        public TableAdjustment EditPerson(LatticeData <Person, PersonRow> latticeData, PersonRow personRow)
        {
            Person currentPerson = null;

            if (personRow.Id == 0)
            {
                currentPerson = new Person();
                _context.Persons.Add(currentPerson);
            }
            else
            {
                currentPerson = _context.Persons.FirstOrDefault(x => x.Id == personRow.Id);
            }

            currentPerson.Age        = personRow.Age;
            currentPerson.Gender     = personRow.Gender;
            currentPerson.Name       = personRow.Name;
            currentPerson.Surname    = personRow.Surname;
            currentPerson.Middlename = personRow.Middlename;
            _context.SaveChanges();

            personRow.Id = currentPerson.Id;

            return(latticeData.Adjust(x => x
                                      .Update(personRow)
//                .Message(LatticeMessage.AtsUser("success", "Editing", "Person saved!"))
                                      ));
        }
Example #3
0
        public TableAdjustment EditAddress(LatticeData <Address, AddressRow> latticeData, AddressRow addressRow)
        {
            Address currentAddress = null;

            if (addressRow.Id == 0)
            {
                currentAddress = new Address();
                _context.Addresses.Add(currentAddress);
            }
            else
            {
                currentAddress = _context.Addresses.FirstOrDefault(address => address.Id == addressRow.Id);
            }

            currentAddress.FlatNumber  = addressRow.FlatNumber;
            currentAddress.HouseNumber = addressRow.HouseNumber;
            currentAddress.Index       = addressRow.Index;
            currentAddress.Locality    = addressRow.Locality;
            currentAddress.Street      = addressRow.Street;
            _context.SaveChanges();

            addressRow.Id = currentAddress.Id;

            return(latticeData.Adjust(wrapper => wrapper
                                      .Update(addressRow)
//                .Message(LatticeMessage.AtsUser("success", "Editing", "Person saved!"))
                                      ));
        }
Example #4
0
        public TableAdjustment EditAts(LatticeData <Ats, AtsRow> latticeData, AtsRow atsRow)
        {
            Ats currentATS = null;

            if (atsRow.Id == 0)
            {
                currentATS = new Ats();
                _context.AtsStations.Add(currentATS);
            }
            else
            {
                currentATS = _context.AtsStations.FirstOrDefault(ats => ats.Id == atsRow.Id);
            }

            currentATS.CityAtsAttributesId          = atsRow.CityAtsAttributesId;
            currentATS.DepartmentalAtsAttributesId  = atsRow.DepartmentalAtsAttributesId;
            currentATS.InstitutionalAtsAttributesId = atsRow.InstitutionalAtsAttributesId;
            currentATS.AtsType = atsRow.AtsType;

            _context.SaveChanges();

            atsRow.Id = currentATS.Id;

            return(latticeData.Adjust(wrapper => wrapper
                                      .Update(atsRow)
//                .Message(LatticeMessage.AtsUser("success", "Editing", "Person saved!"))
                                      ));
        }
Example #5
0
        public TableAdjustment EditPerson(LatticeData <UserAccounting, UserAccountingRow> latticeData, UserAccountingRow userBillRow)
        {
            UserAccounting currentUserBill = null;

            if (userBillRow.Id == 0)
            {
                currentUserBill = new UserAccounting();
                _context.UserAccountings.Add(currentUserBill);
            }
            else
            {
                currentUserBill = _context.UserAccountings.FirstOrDefault(x => x.Id == userBillRow.Id);
            }

            currentUserBill.AtsUserId = userBillRow.UserId;
            currentUserBill.Total     = userBillRow.Total;
            _context.SaveChanges();

            userBillRow.Id = currentUserBill.Id;

            userBillRow.UserName = _context.AtsUsers
                                   .Where(user => user.Id == userBillRow.UserId)
                                   .Select(user => user.Person.Name)
                                   .FirstOrDefault();

            userBillRow.UserSurname = _context.AtsUsers
                                      .Where(user => user.Id == userBillRow.UserId)
                                      .Select(user => user.Person.Surname)
                                      .FirstOrDefault();

            return(latticeData.Adjust(x => x
                                      .Update(userBillRow)
//                .Message(LatticeMessage.AtsUser("success", "Editing", "Person saved!"))
                                      ));
        }
Example #6
0
        public TableAdjustment EditPhoneCall(LatticeData <PhoneHistory, PhoneHistoryRow> latticeData, PhoneHistoryRow phoneCallRow)
        {
            PhoneHistory phoneCall = null;

            if (phoneCallRow.Id == 0)
            {
                phoneCall = new PhoneHistory();
                _context.PhoneHistories.Add(phoneCall);
            }
            else
            {
                phoneCall = _context.PhoneHistories.FirstOrDefault(history => history.Id == phoneCallRow.Id);
            }

            phoneCall.PhoneNumberId = phoneCallRow.PhoneNumberId;
            phoneCall.PhoneDate     = phoneCallRow.PhoneDate;
            phoneCall.Duration      = phoneCallRow.Duration;
            phoneCall.Caller        = phoneCallRow.Caller;
            phoneCall.CallerCity    = phoneCallRow.CallerCity;
            phoneCall.Callee        = phoneCallRow.Callee;
            phoneCall.CalleeCity    = phoneCallRow.CalleeCity;
            _context.SaveChanges();

            phoneCallRow.Id = phoneCall.Id;

            phoneCallRow.PhoneNumber = _context.PhoneNumbers
                                       .Where(number => number.Id == phoneCallRow.PhoneNumberId).Select(number => number.Number)
                                       .FirstOrDefault();

            return(latticeData.Adjust(wrapper => wrapper
                                      .Update(phoneCallRow)
//                .Message(LatticeMessage.AtsUser("success", "Editing", "Person saved!"))
                                      ));
        }
        public ActionResult Save(Application application)
        {
            Application lookup = _context.Applications.Find(application.jobId, application.username);

            if (lookup != null)
            {
                _context.Applications.Remove(lookup);
            }
            _context.Applications.Add(application);
            _context.SaveChanges();

            return(Ok());
        }
        public ActionResult Save(Candidate candidate)
        {
            Candidate lookup = _context.Candidates.Find(candidate.username);

            if (lookup != null)
            {
                _context.Candidates.Remove(lookup);
            }
            _context.Candidates.Add(candidate);
            _context.SaveChanges();

            return(Ok());
        }
Example #9
0
        public ActionResult Save(Job job)
        {
            Job lookup = _context.Jobs.Find(job.id);

            if (lookup != null)
            {
                _context.Jobs.Remove(lookup);
            }
            _context.Jobs.Add(job);
            _context.SaveChanges();

            return(Ok());
        }
        // Actions
        public int Commit()
        {
            transaction = db.Database.BeginTransaction();
            var result = db.SaveChanges();

            transaction.Commit();
            return(result);
        }
Example #11
0
        public TableAdjustment EditAtsUser(LatticeData <AtsUser, AtsUserRow> latticeData, AtsUserRow atsUserRow)
        {
            AtsUser currentAtsUser = null;

            if (atsUserRow.Id == 0)
            {
                currentAtsUser = new AtsUser();
                _context.AtsUsers.Add(currentAtsUser);
            }
            else
            {
                currentAtsUser = _context.AtsUsers.FirstOrDefault(user => user.Id == atsUserRow.Id);
            }

            currentAtsUser.PhoneNumberId = atsUserRow.PhoneNumberId;
            currentAtsUser.PersonId      = atsUserRow.PersonId;

            currentAtsUser.CityBalance      = atsUserRow.CityBalance;
            currentAtsUser.IntercityBalance = atsUserRow.IntercityBalance;
            currentAtsUser.UserFee          = atsUserRow.UserFee;

            currentAtsUser.IntercityAccess  = atsUserRow.IntercityAccess;
            currentAtsUser.PreferentialUser = atsUserRow.PreferentialUser;
            currentAtsUser.PhoneInstalled   = atsUserRow.PhoneInstalled;
            _context.SaveChanges();

            atsUserRow.Id = currentAtsUser.Id;

            atsUserRow.PhoneNumber = _context.PhoneNumbers
                                     .Where(number => number.Id == atsUserRow.PhoneNumberId)
                                     .Select(number => number.Number)
                                     .FirstOrDefault();

            atsUserRow.Person = _context.Persons
                                .Where(person => person.Id == atsUserRow.PersonId)
                                .Select(person => person.Name + " " + person.Surname)
                                .FirstOrDefault();

            return(latticeData.Adjust(wrapper => wrapper
                                      .Update(atsUserRow)
//                .Message(LatticeMessage.AtsUser("success", "Editing", "Person saved!"))
                                      ));
        }
        public TableAdjustment EditPhoneNumber(LatticeData <PhoneNumber, PhoneNumberRow> latticeData, PhoneNumberRow phoneNumberRow)
        {
            PhoneNumber currentPhoneNumber = null;

            if (phoneNumberRow.Id == 0)
            {
                currentPhoneNumber = new PhoneNumber();
                _context.PhoneNumbers.Add(currentPhoneNumber);
            }
            else
            {
                currentPhoneNumber = _context.PhoneNumbers.FirstOrDefault(number => number.Id == phoneNumberRow.Id);
            }

            currentPhoneNumber.AddressId = phoneNumberRow.AddressId;
            currentPhoneNumber.AtsId     = phoneNumberRow.AtsId;
            currentPhoneNumber.Number    = phoneNumberRow.Number;
            currentPhoneNumber.PhoneType = phoneNumberRow.PhoneType;
            currentPhoneNumber.IsFree    = phoneNumberRow.IsFree;
            _context.SaveChanges();

            phoneNumberRow.Id = currentPhoneNumber.Id;

            phoneNumberRow.PhoneNumberAddressShort = _context.Addresses
                                                     .Where(address => address.Id == phoneNumberRow.AddressId)
                                                     .Select(address => address.Street)
                                                     .FirstOrDefault();

            phoneNumberRow.AtsNameAndId = _context.AtsStations
                                          .Where(ats => ats.Id == phoneNumberRow.AtsId)
                                          .Select(ats => ats.AtsType.ToString() + " ATS " + ats.Id.ToString())
                                          .FirstOrDefault();

            return(latticeData.Adjust(wrapper => wrapper
                                      .Update(phoneNumberRow)
//                .Message(LatticeMessage.AtsUser("success", "Editing", "Person saved!"))
                                      ));
        }
Example #13
0
        public TableAdjustment EditCityATSAttribute(LatticeData <CityAtsAttributes, CityATSAttributesRow> latticeData, CityATSAttributesRow cityATSAttributesRow)
        {
            CityAtsAttributes currentAttribute = null;

            if (cityATSAttributesRow.Id == 0)
            {
                currentAttribute = new CityAtsAttributes();
                _context.CityAtsAttributes.Add(currentAttribute);
            }
            else
            {
                currentAttribute = _context.CityAtsAttributes.FirstOrDefault(x => x.Id == cityATSAttributesRow.Id);
            }

            _context.SaveChanges();

            cityATSAttributesRow.Id = currentAttribute.Id;

            return(latticeData.Adjust(x => x
                                      .Update(cityATSAttributesRow)
//                .Message(LatticeMessage.AtsUser("success", "Editing", "Person saved!"))
                                      ));
        }
Example #14
0
        public TableAdjustment EditInstitutionalATSAttributes(LatticeData <InstitutionalAtsAttributes, InstitutionalATSAttributesRow> latticeData, InstitutionalATSAttributesRow institutionalATSAttributesRow)
        {
            InstitutionalAtsAttributes currentAttribute = null;

            if (institutionalATSAttributesRow.Id == 0)
            {
                currentAttribute = new InstitutionalAtsAttributes();
                _context.InstitutionalAtsAttributes.Add(currentAttribute);
            }
            else
            {
                currentAttribute = _context.InstitutionalAtsAttributes.FirstOrDefault(x => x.Id == institutionalATSAttributesRow.Id);
            }

            _context.SaveChanges();

            institutionalATSAttributesRow.Id = currentAttribute.Id;

            return(latticeData.Adjust(x => x
                                      .Update(institutionalATSAttributesRow)
//                .Message(LatticeMessage.AtsUser("success", "Editing", "Person saved!"))
                                      ));
        }
        public TableAdjustment EditDepartmentalATSAttributes(LatticeData <DepartmentalAtsAttributes, DepartmentalATSAttributesRow> latticeData, DepartmentalATSAttributesRow departmentalATSAttributesRow)
        {
            DepartmentalAtsAttributes currentAttribute = null;

            if (departmentalATSAttributesRow.Id == 0)
            {
                currentAttribute = new DepartmentalAtsAttributes();
                _context.DepartmentalAtsAttributes.Add(currentAttribute);
            }
            else
            {
                currentAttribute = _context.DepartmentalAtsAttributes.FirstOrDefault(x => x.Id == departmentalATSAttributesRow.Id);
            }

            _context.SaveChanges();

            departmentalATSAttributesRow.Id = currentAttribute.Id;

            return(latticeData.Adjust(x => x
                                      .Update(departmentalATSAttributesRow)
//                .Message(LatticeMessage.AtsUser("success", "Editing", "Person saved!"))
                                      ));
        }