Пример #1
0
        public UserMaster GetUserdetailsByUsernameAndRole(string name, string userRole)
        {
            UserMaster userMaster = new UserMaster();

            using (var context = new ppmsEntities())
            {
                userMaster = (from a in context.UserMasters
                              where a.UserName == name
                              select a).FirstOrDefault();

                var userRoleMapping = (from a in context.UserRoleMappings
                                       where a.UserId == userMaster.Id
                                       select a).FirstOrDefault();


                var rolemaster = (from a in context.RoleMasters
                                  where a.Id == userRoleMapping.RoleId
                                  select a).FirstOrDefault();

                if (string.Equals(rolemaster.RoleName, userRole, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(userMaster);
                }
                else
                {
                    return(null);
                }
            }
        }
Пример #2
0
 public long CreateCustomer(Customer customer, UserOpMap userOpMap)
 {
     using (var dbContext = new ppmsEntities())
     {
         Customer customerData = new Customer();
         customerData = (from a in dbContext.Customers
                         where a.IsActive == true && a.Id == customer.Id && a.Name == customer.Name
                         select a).FirstOrDefault();
         if (customerData == null)
         {
             try
             {
                 dbContext.Customers.Add(customer);
                 dbContext.SaveChanges();
             }
             catch (Exception ex)
             {
                 throw;
             }
             return(customer.Id);
         }
         else
         {
             throw new Exception("Customer with same data already exist !");
         }
     }
 }
Пример #3
0
        public List <Operations> GetOperationListForUser(int userId)
        {
            List <Operations> opList = new List <Operations>();

            using (var context = new ppmsEntities())
            {
                var userRoleMapping = (from a in context.UserRoleMappings
                                       where a.UserId == userId
                                       select a).FirstOrDefault();

                var rolemaster = (from a in context.RoleMasters
                                  where a.Id == userRoleMapping.RoleId
                                  select a).FirstOrDefault();
                List <RoleOperationMapping> roleOpMapping = new List <RoleOperationMapping>();
                roleOpMapping = (from a in context.RoleOperationMappings
                                 where a.RoleId == userRoleMapping.RoleId
                                 select a).ToList();
                foreach (RoleOperationMapping opMapp in roleOpMapping)
                {
                    Operations      op  = new Operations();
                    OperationMaster opm = new OperationMaster();
                    opm = (from a in context.OperationMasters
                           where a.Id == opMapp.OperationId
                           select a).FirstOrDefault();

                    if (opm != null)
                    {
                        op.OperationName = opm.OperationName;
                        opList.Add(op);
                    }
                }
            }
            return(opList);
        }
Пример #4
0
        public List <Tanker> GetTankerList()
        {
            List <Tanker> tankerList = new List <Tanker>();

            using (var dbContext = new ppmsEntities())
            {
                tankerList = (from a in dbContext.Tankers
                              where a.IsActive == true
                              select a).ToList();
            }
            return(tankerList);
        }
Пример #5
0
        public List <Customer> GetCustomerList()
        {
            List <Customer> customerList = new List <Customer>();

            using (var dbContext = new ppmsEntities())
            {
                customerList = (from a in dbContext.Customers
                                where a.IsActive == true
                                select a).ToList();
            }
            return(customerList);
        }
Пример #6
0
        public DailyTankerReading GetDailyTankerReadingByTankerID(int tankerID)
        {
            DailyTankerReading dailyDailyTankerReading = new DailyTankerReading();

            using (var dbContext = new ppmsEntities())
            {
                dailyDailyTankerReading = (from a in dbContext.DailyTankerReadings
                                           where a.IsActive == true && a.TankerId == tankerID
                                           select a).FirstOrDefault();
            }
            return(dailyDailyTankerReading);
        }
Пример #7
0
        public List <Meter> GetMeterList()
        {
            List <Meter> MeterList = new List <Meter>();

            using (var dbContext = new ppmsEntities())
            {
                MeterList = (from a in dbContext.Meters
                             where a.IsActive == true
                             select a).ToList();
            }
            return(MeterList);
        }
Пример #8
0
        public List <Fuel> GetFuelList()
        {
            List <Fuel> fuelList = new List <Fuel>();

            using (var dbContext = new ppmsEntities())
            {
                fuelList = (from a in dbContext.Fuels
                            where a.IsActive == true
                            select a).ToList();
            }
            return(fuelList);
        }
Пример #9
0
        public UserMaster GetUserdetailsByUsernamePass(string username, string passWord)
        {
            UserMaster userMaster = new UserMaster();

            using (var context = new ppmsEntities())
            {
                userMaster = (from a in context.UserMasters
                              where a.UserName == username && a.Password == passWord
                              select a).FirstOrDefault();
            }
            return(userMaster);
        }
Пример #10
0
        public Fuel GetFuelByFuelID(int fuelID)
        {
            Fuel fuel = new Fuel();

            using (var dbContext = new ppmsEntities())
            {
                fuel = (from a in dbContext.Fuels
                        where a.IsActive == true && a.Id == fuelID
                        select a).FirstOrDefault();
            }
            return(fuel);
        }
Пример #11
0
        public List <CustomerType> GetCustomerType()
        {
            List <CustomerType> customerType = new List <CustomerType>();

            //DateTime myDate = new DateTime();
            using (var dbContext = new ppmsEntities())
            {
                customerType = (from a in dbContext.CustomerTypes
                                where a.IsActive == true
                                select a).ToList();
            }
            return(customerType);
        }
Пример #12
0
        public List <City> GetCityByStateID(string selectedState)
        {
            List <City> listCity = new List <City>();
            int         id       = Convert.ToInt32(selectedState);

            using (var context = new ppmsEntities())
            {
                listCity = (from a in context.Cities
                            where a.StateID == id
                            select a).ToList();
            }
            return(listCity);
        }
Пример #13
0
        public List <State> GetStateList()
        {
            List <State> listSate = new List <State>();

            using (var context = new ppmsEntities())
            {
                listSate = (from a in context.States
                            where a.Name != null
                            select a).ToList();
            }

            return(listSate);
        }
Пример #14
0
        public Tanker GetTankerByID(string tankerID)
        {
            Tanker tanker   = new Tanker();
            int    tankerId = Convert.ToInt32(tankerID);

            using (var dbContext = new ppmsEntities())
            {
                tanker = (from a in dbContext.Tankers
                          where a.IsActive == true && a.Id == tankerId
                          select a).FirstOrDefault();
            }
            return(tanker);
        }
Пример #15
0
        public List <DailyMeterReading> GetDailyMeterReading()
        {
            List <DailyMeterReading> dailyMeterReading = new List <DailyMeterReading>();
            DateTime today = DateTime.Now;

            using (var dbContext = new ppmsEntities())
            {
                dailyMeterReading = (from a in dbContext.DailyMeterReadings
                                     where a.IsActive == true && a.UpdatedOn <= today
                                     orderby a.UpdatedOn descending
                                     select a).ToList();
            }
            return(dailyMeterReading);
        }
Пример #16
0
        public List <DailyFuelCost> GetDailyFuelCost()
        {
            List <DailyFuelCost> dailyFuelCost = new List <DailyFuelCost>();
            DateTime             today         = DateTime.Now;

            using (var dbContext = new ppmsEntities())
            {
                dailyFuelCost = (from a in dbContext.DailyFuelCosts
                                 where a.IsActive == true && a.Date <= today
                                 orderby a.Date descending
                                 select a).ToList();
            }
            return(dailyFuelCost);
        }
Пример #17
0
        public long UpdateTanker(Tanker tanker, DailyTankerReading dailyTankerReading, UserOpMap userOpMap)
        {
            using (var dbContext = new ppmsEntities())
            {
                Tanker tankerData = new Tanker();
                tankerData = (from a in dbContext.Tankers
                              where a.IsActive == true && a.Id == tanker.Id
                              select a).FirstOrDefault();
                tankerData.Description = tanker.Description;
                tankerData.Size        = tanker.Size;
                tankerData.FuelTypeId  = tanker.FuelTypeId;
                tankerData.UpdatedOn   = DateTime.Now;
                tankerData.Updatedby   = Convert.ToInt64(userOpMap.UserID);
                dbContext.SaveChanges();

                DateTime           today = DateTime.Now;
                DailyTankerReading dailyTankerReadingData = new DailyTankerReading();
                dailyTankerReadingData = (from a in dbContext.DailyTankerReadings
                                          where a.UpdatedOn.Value.Day == today.Day &&
                                          a.UpdatedOn.Value.Month == today.Month &&
                                          a.UpdatedOn.Value.Year == today.Year && a.TankerId == tanker.Id && a.IsActive == true
                                          select a).FirstOrDefault();
                if (dailyTankerReadingData == null)
                {
                    dailyTankerReading.TankerId          = tanker.Id;
                    dailyTankerReading.DailyStartReading = dailyTankerReading.DailyStartReading;
                    dailyTankerReading.DailyEndReading   = dailyTankerReading.DailyEndReading;
                    dailyTankerReading.CreatedBy         = Convert.ToInt64(userOpMap.UserID);
                    dailyTankerReading.Updatedby         = Convert.ToInt64(userOpMap.UserID);
                    dailyTankerReading.UpdatedOn         = DateTime.Now;
                    dailyTankerReading.CreatedOn         = DateTime.Now;
                    dailyTankerReading.IsActive          = true;

                    dbContext.DailyTankerReadings.Add(dailyTankerReading);
                    dbContext.SaveChanges();//this generates the Id for DailyTankerReadings
                }
                else
                {
                    dailyTankerReadingData.DailyStartReading = dailyTankerReading.DailyStartReading;
                    dailyTankerReadingData.DailyEndReading   = dailyTankerReading.DailyEndReading;
                    dailyTankerReadingData.Updatedby         = Convert.ToInt64(userOpMap.UserID);
                    dailyTankerReadingData.UpdatedOn         = DateTime.Now;
                    dbContext.SaveChanges();//this generates the Id for DailyTankerReadings
                }
                return(dailyTankerReading.Id);
            }
        }
Пример #18
0
        public bool ValidateUserLogin(string username, string pass)
        {
            UserMaster userMaster = new UserMaster();

            using (var context = new ppmsEntities())
            {
                userMaster = (from a in context.UserMasters
                              where a.UserName == username && a.Password == pass
                              select a).FirstOrDefault();
            }
            if (userMaster != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #19
0
        public string GetUserRole(long userID)
        {
            string role = string.Empty;

            using (var context = new ppmsEntities())
            {
                var userRoleMapping = (from a in context.UserRoleMappings
                                       where a.UserId == userID
                                       select a).FirstOrDefault();

                var rolemaster = (from a in context.RoleMasters
                                  where a.Id == userRoleMapping.RoleId
                                  select a).FirstOrDefault();
                if (rolemaster != null)
                {
                    role = rolemaster.RoleName;
                }
            }
            return(role);
        }
Пример #20
0
        public long UpdateCutsomer(Customer customerData)
        {
            using (var dbContext = new ppmsEntities())
            {
                Customer customer = new Customer();
                customer = (from a in dbContext.Customers
                            where a.IsActive == true && a.Id == customerData.Id
                            select a).FirstOrDefault();
                customer.EmailId        = customerData.EmailId;
                customer.AddressLineOne = customerData.AddressLineOne;
                customer.AddressLineTwo = customerData.AddressLineTwo;
                customer.ContactNumber  = Convert.ToInt64(customerData.ContactNumber);
                customer.City           = customerData.City;
                customer.State          = customerData.State;
                customer.UpdatedOn      = DateTime.Now;
                customer.Updatedby      = customerData.Updatedby;
                customer.CustomerTypeId = Convert.ToInt32(customerData.CustomerTypeId);

                dbContext.SaveChanges();
                return(customerData.Id);
            }
        }
Пример #21
0
        public long UpdateFuel(Fuel fuel, DailyFuelCost dailyFuelCost, UserOpMap userOpMap)
        {
            using (var dbContext = new ppmsEntities())
            {
                Fuel fuelData = new Fuel();
                fuelData = (from a in dbContext.Fuels
                            where a.IsActive == true && a.Id == fuel.Id
                            select a).FirstOrDefault();
                fuelData.Description = fuel.Description;
                fuelData.Type        = fuel.Type;
                dbContext.SaveChanges();

                dailyFuelCost.CreatedBy = Convert.ToInt64(userOpMap.UserID);
                dailyFuelCost.Updatedby = Convert.ToInt64(userOpMap.UserID);
                dailyFuelCost.UpdatedOn = DateTime.Now;
                dailyFuelCost.CreatedOn = DateTime.Now;
                dailyFuelCost.IsActive  = true;

                dbContext.DailyFuelCosts.Add(dailyFuelCost);
                dbContext.SaveChanges();//this generates the Id for customer
                return(dailyFuelCost.Id);
            }
        }
Пример #22
0
        public long CreateMeter(Meter meter, DailyMeterReading dailyMeterReading, UserOpMap userOpMap)
        {
            using (var dbContext = new ppmsEntities())
            {
                Meter meterData = new Meter();
                meterData = (from a in dbContext.Meters
                             where a.IsActive == true && a.Name == meter.Name
                             select a).FirstOrDefault();
                if (meterData == null)
                {
                    //Create Meter
                    meter.IsActive  = true;
                    meter.CreatedBy = Convert.ToInt64(userOpMap.UserID);
                    meter.Updatedby = Convert.ToInt64(userOpMap.UserID);
                    meter.CreatedOn = DateTime.Now;
                    meter.UpdatedOn = DateTime.Now;
                    dbContext.Meters.Add(meter);
                    dbContext.SaveChanges();
                    int meterID = meter.Id;

                    dailyMeterReading.CreatedBy = Convert.ToInt64(userOpMap.UserID);
                    dailyMeterReading.Updatedby = Convert.ToInt64(userOpMap.UserID);
                    dailyMeterReading.UpdatedOn = DateTime.Now;
                    dailyMeterReading.CreatedOn = DateTime.Now;
                    dailyMeterReading.IsActive  = true;
                    dailyMeterReading.MeterId   = meterID;

                    dbContext.DailyMeterReadings.Add(dailyMeterReading);
                    dbContext.SaveChanges();
                    return(dailyMeterReading.Id);
                }
                else
                {
                    throw new Exception("Meter already exist !");
                }
            }
        }
Пример #23
0
        public long CreateFuel(Fuel fuel, DailyFuelCost dailyFuelCost, UserOpMap userOpMap)
        {
            using (var dbContext = new ppmsEntities())
            {
                Fuel fuelData = new Fuel();
                fuelData = (from a in dbContext.Fuels
                            where a.IsActive == true && a.Name == fuel.Name && a.Type == fuel.Type
                            select a).FirstOrDefault();
                if (fuelData == null)
                {
                    //Create Fuel
                    fuel.IsActive  = true;
                    fuel.CreatedBy = Convert.ToInt64(userOpMap.UserID);
                    fuel.Updatedby = Convert.ToInt64(userOpMap.UserID);
                    fuel.CreatedOn = DateTime.Now;
                    fuel.UpdatedOn = DateTime.Now;
                    dbContext.Fuels.Add(fuel);
                    dbContext.SaveChanges();
                    int fuelID = fuel.Id;

                    dailyFuelCost.CreatedBy  = Convert.ToInt64(userOpMap.UserID);
                    dailyFuelCost.Updatedby  = Convert.ToInt64(userOpMap.UserID);
                    dailyFuelCost.UpdatedOn  = DateTime.Now;
                    dailyFuelCost.CreatedOn  = DateTime.Now;
                    dailyFuelCost.IsActive   = true;
                    dailyFuelCost.FuelTypeId = fuelID;

                    dbContext.DailyFuelCosts.Add(dailyFuelCost);
                    dbContext.SaveChanges();//this generates the Id for customer
                    return(dailyFuelCost.Id);
                }
                else
                {
                    throw new Exception("Fuel already exist !");
                }
            }
        }