Beispiel #1
0
        public async Task <Response> AddBank(BankVM bank)
        {
            var Dto = Mapper.Map <BankVM, Bank>(bank);

            Bank Exist = await _db.Banks.Where(x => x.Bank1.Trim() == bank.Bank1.Trim()).FirstOrDefaultAsync();

            if (Exist != null)
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoAlreadyExist, (int)Constant.httpStatus.NoContent, 0));
            }

            _db.Banks.Add(Dto);

            int result = await _db.SaveChangesAsync();

            if (result == 1)
            {
                // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result));
            }
        }
Beispiel #2
0
        public async Task <Response> AddContractType(ContractTypeVM contracttype)
        {
            var Dto = Mapper.Map <ContractTypeVM, ContractType>(contracttype);

            ContractType Exist = await _db.ContractTypes.Where(x => x.Type.Trim() == contracttype.Type.Trim()).FirstOrDefaultAsync();

            if (Exist != null)
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoAlreadyExist, (int)Constant.httpStatus.NoContent, 0));
            }

            _db.ContractTypes.Add(Dto);

            int result = await _db.SaveChangesAsync();

            if (result == 1)
            {
                // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result));
            }
        }
Beispiel #3
0
        public async Task <Response> AddGood(GoodsTypeVM goods)
        {
            var goodsDto = Mapper.Map <GoodsTypeVM, GoodsType>(goods);

            GoodsType goodsExist = await _db.GoodsTypes.Where(x => x.Goods.Trim() == goods.Goods.Trim()).FirstOrDefaultAsync();

            if (goodsExist != null)
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoAlreadyExist, (int)Constant.httpStatus.NoContent, 0));
            }

            _db.GoodsTypes.Add(goodsDto);

            int result = await _db.SaveChangesAsync();

            if (result == 1)
            {
                // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result));
            }
        }
Beispiel #4
0
        public async Task <Response> updateDo(DorderVM dorder)
        {
            try
            {
                Dorder DTO = Mapper.Map <DorderVM, Dorder>(dorder);



                _db.Dorders.Add(DTO);

                int result = await _db.SaveChangesAsync();

                if (result == 1)
                {
                    // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                    return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
                }
                else
                {
                    return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <int> .ResponseStatus(true, e.Message, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Beispiel #5
0
        public async Task <Response> AddDo(DorderVM dorder)
        {
            var Dto = Mapper.Map <DorderVM, Dorder>(dorder);

            Dorder Exist = await _db.Dorders.Where(x => x.DoNumber == dorder.DoNumber).FirstOrDefaultAsync();

            if (Exist != null)
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoAlreadyExist, (int)Constant.httpStatus.NoContent, -1));
            }

            _db.Dorders.Add(Dto);

            int result = await _db.SaveChangesAsync();

            if (result == 1)
            {
                // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result));
            }
        }
Beispiel #6
0
        public async Task <Response> UpdateContractQty(ContractVM contract)
        {
            try
            {
                Contract DTO = await _db.Contracts.Where(x => x.ContractNo == contract.ContractNo).FirstOrDefaultAsync();

                DTO.TotatQty = (DTO.TotatQty + contract.TotatQty);



                int result = await _db.SaveChangesAsync();

                if (result == 1)
                {
                    // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                    return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
                }
                else
                {
                    return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <int> .ResponseStatus(true, e.Message, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Beispiel #7
0
        public async Task <Response> RemoveContractType(ContractTypeVM contracttype)
        {
            try
            {
                var DTO = await _db.ContractTypes.Where(x => x.Id == contracttype.Id).FirstOrDefaultAsync();

                _db.ContractTypes.Remove(DTO);

                int result = await _db.SaveChangesAsync();

                if (result == 1)
                {
                    // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                    return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
                }
                else
                {
                    return(GenericResponses <int> .ResponseStatus(true, Constant.MSGFailed, (int)Constant.httpStatus.NoContent, result));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <int> .ResponseStatus(true, e.Message, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Beispiel #8
0
        public async Task <Response> GetAllBilties()
        {
            try
            {
                List <BiltyVM> response = new List <BiltyVM>();
                //var users =  _db.Users.Select(x => x).ToList();
                var DTO = await _db.Bilties.ToListAsync();

                //   Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                //   Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());
                response = Mapper.Map <IEnumerable <Bilty>, List <BiltyVM> >(DTO);
                if (response.Count() > 0)
                {
                    return(GenericResponses <IEnumerable <BiltyVM> > .ResponseStatus(false, response.Count() + Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, response));
                }
                else
                {
                    return(GenericResponses <IEnumerable <BiltyVM> > .ResponseStatus(false, Constant.MDGNoRecordFound, (int)Constant.httpStatus.NoContent, response.ToList()));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <DorderVM> .ResponseStatus(true));
            }
        }
Beispiel #9
0
        public async Task <Response> AddBilty(BiltyVM bilty, decimal[] dos)
        {
            var Dto = Mapper.Map <BiltyVM, Bilty>(bilty);



            _db.Bilties.Add(Dto);

            int result = await _db.SaveChangesAsync();

            if (result == 1)
            {
                // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());


                foreach (decimal donumber in dos)
                {
                    BiltyToDo biltyToDoObj = new BiltyToDo();
                    biltyToDoObj.Biltyno  = Dto.BiltyNo;
                    biltyToDoObj.Donumber = donumber;
                    _db.BiltyToDos.Add(biltyToDoObj);
                    int resultDos = await _db.SaveChangesAsync();
                }



                return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result));
            }
        }
Beispiel #10
0
        public async Task <Response> AddVehicle(VehicleVM vehicle)
        {
            var vehicleDto = Mapper.Map <VehicleVM, vehicle>(vehicle);

            vehicle vehicleExist = await _db.vehicles.Where(x => x.RegNumber.Trim() == vehicle.RegNumber.Trim()).FirstOrDefaultAsync();

            if (vehicleExist != null)
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoAlreadyExist, (int)Constant.httpStatus.NoContent, 0));
            }

            _db.vehicles.Add(vehicleDto);

            int result = await _db.SaveChangesAsync();

            if (result == 1)
            {
                // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result));
            }
        }
Beispiel #11
0
        public async Task <Response> GetDoByBilty(decimal biltynumber)
        {
            var DTOBiltyToDo = await _db.BiltyToDos.Where(x => x.Biltyno == biltynumber).ToListAsync();

            if (DTOBiltyToDo != null)
            {
                return(GenericResponses <IEnumerable <BiltyToDo> > .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, DTOBiltyToDo));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoRecordFound, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Beispiel #12
0
        public async Task <Response> GetallVehicles()
        {
            try
            {
                List <VehicleVM> response = new List <VehicleVM>();
                //var users =  _db.Users.Select(x => x).ToList();
                var vehiclesDTO = await _db.vehicles.ToListAsync();

                //   Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                //   Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());
                // response = Mapper.Map<IEnumerable<GoodsType>, List<GoodsTypeVM>>(goods);

                foreach (var vehicle in vehiclesDTO)
                {
                    VehicleVM obj = new VehicleVM();
                    obj.Capacity            = vehicle.Capacity;
                    obj.CreatedOn           = vehicle.CreatedOn;
                    obj.EcomID              = vehicle.EcomID;
                    obj.Id                  = vehicle.Id;
                    obj.Manufacturer        = vehicle.Manufacturer;
                    obj.Model               = vehicle.Model;
                    obj.RegNumber           = vehicle.RegNumber;
                    obj.Status              = vehicle.Status;
                    obj.StatusName          = _shareRepo.GetVehicleStatusByID((int)vehicle.Status);
                    obj.Type                = vehicle.Type;
                    obj.TypeName            = _shareRepo.GetVehicleTypeID((int)vehicle.Type);
                    obj.Unit                = vehicle.Unit;
                    obj.UnitName            = _shareRepo.GetUnitByID((int)vehicle.Unit);
                    obj.IsContractorVehicle = vehicle.IsContractorVehicle;
                    obj.ContractorId        = vehicle.ContractorId;

                    response.Add(obj);
                }

                if (response.Count() > 0)
                {
                    return(GenericResponses <IEnumerable <VehicleVM> > .ResponseStatus(false, response.Count() + Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, response));
                }
                else
                {
                    return(GenericResponses <IEnumerable <VehicleVM> > .ResponseStatus(false, Constant.MDGNoRecordFound, (int)Constant.httpStatus.NoContent, response.ToList()));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <VehicleVM> .ResponseStatus(true));
            }
        }
Beispiel #13
0
        public Response GetVehicleById(int vehicleId)
        {
            var vehicleDTO = _db.vehicles.Where(x => x.Id == vehicleId).FirstOrDefault();

            //  VehicleVM vehicleVm= Mapper.Map<vehicle, VehicleVM>(vehicleDTO);

            if (vehicleDTO != null)
            {
                return(GenericResponses <vehicle> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, vehicleDTO));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MSGFailed, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Beispiel #14
0
        public Response GetallVehicleTypes()
        {
            List <DropDownListModel> Lst = new List <DropDownListModel>();

            foreach (DictionaryEntry entry in VehicleTypes)
            {
                DropDownListModel obj = new DropDownListModel();
                obj.Value = (int)entry.Key;
                obj.Text  = entry.Value.ToString();
                Lst.Add(obj);
                // Console.WriteLine("{0}, {1}", entry.Key, entry.Value);
            }

            return(GenericResponses <List <DropDownListModel> > .ResponseStatus(false, Lst.Count() + Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, Lst));
        }
        public Response GetallSelectListContractors()
        {
            var DTO = _db.Contractors.ToList();
            List <DropDownListModel> Lst = new List <DropDownListModel>();

            foreach (var DTobj in DTO)
            {
                DropDownListModel obj = new DropDownListModel();
                obj.Value = (int)DTobj.Id;
                obj.Text  = DTobj.Name;
                Lst.Add(obj);
                // Console.WriteLine("{0}, {1}", entry.Key, entry.Value);
            }

            return(GenericResponses <List <DropDownListModel> > .ResponseStatus(false, Lst.Count() + Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, Lst));
        }
Beispiel #16
0
        public Response GetallSelectListVehicles()
        {
            var vehiclesDTO = _db.vehicles.ToList();
            List <DropDownListModel> Lst = new List <DropDownListModel>();

            foreach (var vehicle  in vehiclesDTO)
            {
                DropDownListModel obj = new DropDownListModel();
                obj.Value = (int)vehicle.Id;
                obj.Text  = vehicle.RegNumber.ToString();
                Lst.Add(obj);
                // Console.WriteLine("{0}, {1}", entry.Key, entry.Value);
            }

            return(GenericResponses <List <DropDownListModel> > .ResponseStatus(false, Lst.Count() + Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, Lst));
        }
        public Response ValidateUser(UserVM user)
        {
            UserVM response = new UserVM();
            UserVM r        = new UserVM();
            User   result   = _db.Users.Where(x => x.Email == user.Email && x.Password == user.Password).FirstOrDefault();

            if (result != null)
            {
                // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());
                response = Mapper.Map <User, UserVM>(result);
                return(GenericResponses <UserVM> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, response));
            }
            else
            {
                return(GenericResponses <UserVM> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, null));
            }
        }
Beispiel #18
0
        public async Task <Response> GetBiltyByDo(decimal donumber)
        {
            var DTOBiltyToDo = await _db.BiltyToDos.Where(x => x.Donumber == donumber).FirstOrDefaultAsync();


            var DTO = await _db.Bilties.Where(x => x.BiltyNo == DTOBiltyToDo.Biltyno).FirstOrDefaultAsync();

            if (DTO != null)
            {
                var Obj = Mapper.Map <Bilty, BiltyVM>(DTO);

                return(GenericResponses <BiltyVM> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, Obj));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoRecordFound, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Beispiel #19
0
        public async Task <Response> GetALLParties()
        {
            try
            {
                List <PartyVM> response = new List <PartyVM>();
                //var users =  _db.Users.Select(x => x).ToList();
                var DTO = await _db.Parties.ToListAsync();

                foreach (var party in DTO)
                {
                    PartyVM obj = new PartyVM();
                    obj.ConectPerson = party.ConectPerson;
                    obj.CreatedOn    = party.CreatedOn;
                    obj.EcomID       = party.EcomID;
                    obj.Id           = party.Id;
                    obj.IsSubParty   = party.IsSubParty;
                    obj.ParentId     = party.ParentId;
                    obj.Phone        = party.Phone;
                    obj.Party1       = party.Party1;
                    if (party.ParentId != null && party.ParentId != 0)
                    {
                        obj.ParentPartyName = GetPartyById((int)party.ParentId).Party1;
                    }
                    response.Add(obj);
                }

                //   Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                //   Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());
                // response = Mapper.Map<IEnumerable<Expense>, List<ExpenseVM>>(DTO);
                if (response.Count() > 0)
                {
                    return(GenericResponses <IEnumerable <PartyVM> > .ResponseStatus(false, response.Count() + Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, response));
                }
                else
                {
                    return(GenericResponses <IEnumerable <PartyVM> > .ResponseStatus(false, Constant.MDGNoRecordFound, (int)Constant.httpStatus.NoContent, response.ToList()));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <PartyVM> .ResponseStatus(true));
            }
        }
Beispiel #20
0
        public async Task <Response> GetSetting()
        {
            try
            {
                var DTO = await _db.Settings.FirstOrDefaultAsync();

                if (DTO != null)
                {
                    return(GenericResponses <Setting> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, DTO));
                }
                else
                {
                    return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoRecordFound, (int)Constant.httpStatus.NoContent, 0));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <int> .ResponseStatus(true, e.Message, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Beispiel #21
0
        public async Task <Response> GetBilty(decimal biltynumber)
        {
            try
            {
                var DTO = await _db.Bilties.Where(x => x.BiltyNo == biltynumber).FirstOrDefaultAsync();

                if (DTO != null)
                {
                    var Obj = Mapper.Map <Bilty, BiltyVM>(DTO);

                    return(GenericResponses <BiltyVM> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, Obj));
                }
                else
                {
                    return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoRecordFound, (int)Constant.httpStatus.NoContent, 0));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <int> .ResponseStatus(true, e.Message, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Beispiel #22
0
        public async Task <Response> GetContract(int Id)
        {
            try
            {
                var DTO = await _db.Contracts.Where(x => x.Id == Id).FirstOrDefaultAsync();

                if (DTO != null)
                {
                    var ContratObj = Mapper.Map <Contract, ContractVM>(DTO);

                    return(GenericResponses <ContractVM> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, ContratObj));
                }
                else
                {
                    return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoRecordFound, (int)Constant.httpStatus.NoContent, 0));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <int> .ResponseStatus(true, e.Message, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Beispiel #23
0
        public async Task <Response> GetDo(decimal Id)
        {
            try
            {
                var DTO = await _db.Dorders.Where(x => x.DoNumber == Id).FirstOrDefaultAsync();

                if (DTO != null)
                {
                    var Obj = Mapper.Map <Dorder, DorderVM>(DTO);

                    return(GenericResponses <DorderVM> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, Obj));
                }
                else
                {
                    return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoRecordFound, (int)Constant.httpStatus.NoContent, 0));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <int> .ResponseStatus(true, e.Message, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Beispiel #24
0
        public async Task <Response> GetALLExpenses()
        {
            try
            {
                List <ExpenseVM> response = new List <ExpenseVM>();
                //var users =  _db.Users.Select(x => x).ToList();
                var DTO = await _db.Expenses.ToListAsync();

                foreach (var expense in DTO)
                {
                    ExpenseVM obj = new ExpenseVM();
                    obj.Description = expense.Description;
                    obj.EcomID      = expense.EcomID;
                    obj.Expense1    = expense.Expense1;
                    obj.Id          = expense.Id;
                    obj.Type        = expense.Type;
                    obj.TypeName    = GetExpenseTypeByID((int)obj.Type);
                    response.Add(obj);
                }

                //   Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                //   Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());
                // response = Mapper.Map<IEnumerable<Expense>, List<ExpenseVM>>(DTO);
                if (response.Count() > 0)
                {
                    return(GenericResponses <IEnumerable <ExpenseVM> > .ResponseStatus(false, response.Count() + Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, response));
                }
                else
                {
                    return(GenericResponses <IEnumerable <ExpenseVM> > .ResponseStatus(false, Constant.MDGNoRecordFound, (int)Constant.httpStatus.NoContent, response.ToList()));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <ExpenseVM> .ResponseStatus(true));
            }
        }
Beispiel #25
0
        public async Task <Response> RemoveBilty(BiltyVM bilty)
        {
            var DTObilty = await _db.BiltyToDos.Where(x => x.Biltyno == bilty.BiltyNo).ToListAsync();

            int result = 0;

            foreach (BiltyToDo obj in DTObilty)
            {
                _db.BiltyToDos.Remove(obj);
                result = await _db.SaveChangesAsync();
            }



            try
            {
                var DTO = await _db.Bilties.Where(x => x.BiltyNo == bilty.BiltyNo).FirstOrDefaultAsync();

                _db.Bilties.Remove(DTO);

                int resultbilty = await _db.SaveChangesAsync();

                if (resultbilty == 1)
                {
                    // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                    return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
                }
                else
                {
                    return(GenericResponses <int> .ResponseStatus(true, Constant.MSGFailed, (int)Constant.httpStatus.NoContent, result));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <int> .ResponseStatus(true, e.Message, (int)Constant.httpStatus.NoContent, 0));
            }
        }
        public Response GetModules()
        {
            try
            {
                List <ModuleVM> response = new List <ModuleVM>();
                var             modules  = _db.Modules.Select(x => x).ToList();
                //  Mapper.Initialize(cfg => cfg.CreateMap<Module, ModuleVM>());
                response = Mapper.Map <IEnumerable <Module>, List <ModuleVM> >(modules);

                if (response.Count() > 0)
                {
                    return(GenericResponses <IEnumerable <ModuleVM> > .ResponseStatus(false, response.Count() + Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, response));
                }
                else
                {
                    return(GenericResponses <IEnumerable <ModuleVM> > .ResponseStatus(false, Constant.MDGNoRecordFound, (int)Constant.httpStatus.NoContent, response.ToList()));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <ModuleVM> .ResponseStatus(true));
            }
        }
Beispiel #27
0
        public async Task <Response> GetAddressHistory(int party)
        {
            try
            {
                AdressHistory DTO = await _db.AdressHistories.Where(x => x.Party == party).FirstOrDefaultAsync();

                AdressHistoryVM address = new AdressHistoryVM();
                if (DTO != null)
                {
                    address.EnglisgAddress = DTO.EnglisgAddress;
                    address.UrduAddress    = DTO.UrduAddress;

                    return(GenericResponses <AdressHistoryVM> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, address));
                }
                else
                {
                    return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoRecordFound, (int)Constant.httpStatus.NoContent, 0));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <int> .ResponseStatus(true, e.Message, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Beispiel #28
0
        public async Task <Response> AddSetting(Setting setting)
        {
            Setting Exist = await _db.Settings.FirstOrDefaultAsync();

            if (Exist != null)
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoAlreadyExist, (int)Constant.httpStatus.NoContent, -1));
            }

            _db.Settings.Add(Exist);

            int result = await _db.SaveChangesAsync();

            if (result == 1)
            {
                // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result));
            }
        }
Beispiel #29
0
        public async Task <Response> UpdateSetting(Setting setting)
        {
            try
            {
                _db.Settings.Add(setting);

                int result = await _db.SaveChangesAsync();

                if (result == 1)
                {
                    // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                    return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
                }
                else
                {
                    return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <int> .ResponseStatus(true, e.Message, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Beispiel #30
0
        public async Task <Response> GetDriverByVehicle(int vehicleId)
        {
            try
            {
                var DTO = await _db.Drivers.Where(x => x.Vehicle == vehicleId).FirstOrDefaultAsync();



                if (DTO != null)
                {
                    // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());
                    var Obj = Mapper.Map <Driver, DriverVM>(DTO);
                    return(GenericResponses <DriverVM> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, Obj));
                }
                else
                {
                    return(GenericResponses <int> .ResponseStatus(true, Constant.MSGFailed, (int)Constant.httpStatus.NoContent, 0));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <int> .ResponseStatus(true, e.Message, (int)Constant.httpStatus.NoContent, 0));
            }
        }