コード例 #1
0
ファイル: CustomerRepository.cs プロジェクト: mformihir/SBS
        public string UpdateCustomer(Customer customer)
        {
            var customerFromDb = _db.Customer.Where(c => c.Id == customer.Id && c.IsActive == true).FirstOrDefault();

            if (customerFromDb != null)
            {
                customerFromDb.Email = customer.Email;

                var salt     = AuthenticationHelper.GenerateSalt(10);
                var password = AuthenticationHelper.EncodePassword(customer.Password, salt);

                customerFromDb.Password    = password;
                customerFromDb.Salt        = salt;
                customerFromDb.Address1    = customer.Address1;
                customerFromDb.Address2    = customer.Address2;
                customerFromDb.Comments    = customer.Comments;
                customerFromDb.ContactNo   = customer.ContactNo;
                customerFromDb.Name        = customer.Name;
                customerFromDb.UpdatedDate = DateTime.Now;
                customerFromDb.Zipcode     = customer.Zipcode;

                _db.Entry(customerFromDb).State = EntityState.Modified;
                _db.SaveChanges();
                return("Success");
            }
            return("Error");
        }
コード例 #2
0
        public string AcceptAppointment(int id)
        {
            var appointmentFromDb = _db.Appointment.Where(c => c.Id == id).FirstOrDefault();

            if (appointmentFromDb != null)
            {
                appointmentFromDb.Status = "Accepted";

                _db.Entry(appointmentFromDb).State = EntityState.Modified;
                _db.SaveChanges();
                return("Success");
            }
            return("Invalid Appointment");
        }
コード例 #3
0
        public string UpdateService(Service Service)
        {
            var ServiceFromDb = _db.Service.Where(c => c.Id == Service.Id && c.IsActive == true).FirstOrDefault();

            if (ServiceFromDb != null)
            {
                ServiceFromDb.Name             = Service.Name;
                ServiceFromDb.Duration         = Service.Duration;
                ServiceFromDb.Price            = Service.Price;
                _db.Entry(ServiceFromDb).State = EntityState.Modified;
                _db.SaveChanges();
                return("Success");
            }
            return("Error");
        }
コード例 #4
0
ファイル: MechanicRepository.cs プロジェクト: mformihir/SBS
        public string UpdateMechanic(Mechanic Mechanic)
        {
            var MechanicFromDb = _db.Mechanic.Where(c => c.Id == Mechanic.Id && c.IsActive == true).FirstOrDefault();

            if (MechanicFromDb != null)
            {
                MechanicFromDb.Email = Mechanic.Email;

                MechanicFromDb.ContactNo   = Mechanic.ContactNo;
                MechanicFromDb.CreatedBy   = Mechanic.CreatedBy;
                MechanicFromDb.Name        = Mechanic.Name;
                MechanicFromDb.DealerId    = Mechanic.DealerId;
                MechanicFromDb.UpdatedBy   = Mechanic.UpdatedBy;
                MechanicFromDb.UpdatedDate = DateTime.Now;

                _db.Entry(MechanicFromDb).State = EntityState.Modified;
                _db.SaveChanges();
                return("Success");
            }
            return("Error");
        }
コード例 #5
0
ファイル: VehicleRepository.cs プロジェクト: mformihir/SBS
        public string UpdateVehicle(Vehicle Vehicle)
        {
            var VehicleFromDb = _db.Vehicle.Where(c => c.Id == Vehicle.Id && c.IsActive == true).FirstOrDefault();

            if (VehicleFromDb != null)
            {
                VehicleFromDb.LicensePlate     = Vehicle.LicensePlate;
                VehicleFromDb.Brand            = Vehicle.Brand;
                VehicleFromDb.RegistrationDate = Vehicle.RegistrationDate;
                VehicleFromDb.Model            = Vehicle.Model;
                VehicleFromDb.CustomerId       = Vehicle.CustomerId;
                VehicleFromDb.UpdatedBy        = Vehicle.UpdatedBy;
                VehicleFromDb.UpdatedDate      = DateTime.Now;


                _db.Entry(VehicleFromDb).State = EntityState.Modified;
                _db.SaveChanges();
                return("Success");
            }
            return("Error");
        }
コード例 #6
0
ファイル: DealerRepository.cs プロジェクト: mformihir/SBS
        public string UpdateDealer(Dealer Dealer)
        {
            var DealerFromDb = _db.Dealer.Where(c => c.Id == Dealer.Id && c.IsActive == true).FirstOrDefault();

            if (DealerFromDb != null)
            {
                DealerFromDb.Email       = Dealer.Email;
                DealerFromDb.Address1    = Dealer.Address1;
                DealerFromDb.Address2    = Dealer.Address2;
                DealerFromDb.ContactNo   = Dealer.ContactNo;
                DealerFromDb.CreatedBy   = Dealer.CreatedBy;
                DealerFromDb.Name        = Dealer.Name;
                DealerFromDb.UpdatedBy   = Dealer.UpdatedBy;
                DealerFromDb.UpdatedDate = DateTime.Now;
                DealerFromDb.Zipcode     = Dealer.Zipcode;

                _db.Entry(DealerFromDb).State = EntityState.Modified;
                _db.SaveChanges();
                return("Success");
            }
            return("Error");
        }