Example #1
0
        public async Task DeleteBranch(BranchCreateModel data)
        {
            try
            {
                switch (data.companyType)
                {
                case "MSP":
                    await Task.Run(() => ManageMSP.DeleteMSPLocationBranch(data.id, "Branch"));

                    break;

                case "Customer":
                    await Task.Run(() => ManageCustomer.DeleteCustomerLocationBranch(data.id, "Branch"));

                    break;

                case "Supplier":
                    await Task.Run(() => ManageSupplier.DeleteSupplierBranchLocation(data.id, "Branch"));

                    break;
                }

                await Task.Run(() => ManageBranch.DeleteBranch(data.id));
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #2
0
        public async Task <BranchCreateModel> CreateBranch(BranchCreateModel data)
        {
            try
            {
                BranchCreateModel model      = null;
                tblBranch         dataBranch = await Task.Run(() => ManageBranch.InsertBranch(data.ConvertTotblBranch()));

                model         = (await Task.Run(() => ManageBranch.GetBranchDetails(dataBranch.ID))).ConvertToBranch();
                data.branchId = model.id;

                switch (data.companyType)
                {
                case "MSP":
                    tblMSPLocationBranch dataMSP = await Task.Run(() => ManageMSP.InsertMSPLocationBranch(data.ConvertTotblMSPLocationBranch()));

                    break;

                case "Customer":
                    tblCustomerLocationBranch dataCustomer = await Task.Run(() => ManageCustomer.InsertCustomerLocationBranch(data.ConvertTotblCustomerLocationBranch()));

                    break;

                case "Supplier":
                    tblSupplierLocationBranch dataSupplier = await Task.Run(() => ManageSupplier.InsertSupplierLocationBranch(data.ConvertTotblSupplierLocationBranch()));

                    break;
                }

                return(model);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Example #3
0
        public async Task <LocationCreateModel> CreateLocation(LocationCreateModel data)
        {
            try
            {
                LocationCreateModel model        = null;
                tblLocation         dataLocation = await Task.Run(() => ManageLocation.InsertLocation(data.ConvertTotblLocation()));

                model           = (await Task.Run(() => ManageLocation.GetLocationDetails(dataLocation.ID))).ConvertToLocation();
                data.locationId = model.id;

                switch (data.companyType)
                {
                case "MSP":
                    tblMSPLocationBranch dataMSP = await Task.Run(() => ManageMSP.InsertMSPLocationBranch(data.ConvertTotblMSPLocationBranch()));

                    break;

                case "Customer":
                    tblCustomerLocationBranch dataCustomer = await Task.Run(() => ManageCustomer.InsertCustomerLocationBranch(data.ConvertTotblCustomerLocationBranch()));

                    break;

                case "Supplier":
                    tblSupplierLocationBranch dataSupplier = await Task.Run(() => ManageSupplier.InsertSupplierLocationBranch(data.ConvertTotblSupplierLocationBranch()));

                    break;
                }

                return(model);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #4
0
        public async Task <List <BranchCreateModel> > GetBranchs(LocationBranchModel data)
        {
            try
            {
                List <BranchCreateModel> model    = null;
                List <tblBranch>         resModel = null;
                long Id = data != null?Convert.ToInt64(data.companyId) : 0;

                switch (data.companyType)
                {
                case "MSP":
                    long id = Convert.ToInt64(ConfigurationManager.AppSettings["MSP_ID"]);
                    Id       = id != null ? id : Id;
                    resModel = await Task.Run(() => ManageMSP.GetMSPBranches(Id, data.locationId));

                    break;

                case "Customer":
                    resModel = await Task.Run(() => ManageCustomer.GetCustomerBranches(Id, data.locationId));

                    break;

                case "Supplier":
                    resModel = await Task.Run(() => ManageSupplier.GetSupplierBranches(Id, data.locationId));

                    break;
                }
                model = resModel.Select(a => a.ConvertToBranch()).ToList();

                return(model);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #5
0
        public async Task <List <LocationCreateModel> > GetLocations(LocationCreateModel data)
        {
            try
            {
                List <LocationCreateModel> res     = null;
                List <tblLocation>         resData = null;
                long Id = data != null?Convert.ToInt64(data.companyId) : 0;

                switch (data.companyType)
                {
                case "MSP":
                    long id = Convert.ToInt64(ConfigurationManager.AppSettings["MSP_ID"]);
                    Id      = id != null ? id : Id;
                    resData = await Task.Run(() => ManageMSP.GetMSPLocation(Id));

                    break;

                case "Customer":
                    resData = await Task.Run(() => ManageCustomer.GetCustomerLocation(Id));

                    break;

                case "Supplier":
                    resData = await Task.Run(() => ManageSupplier.GetSupplierLocation(Id));

                    break;
                }
                res = resData.Select(a => a.ConvertToLocation()).ToList();

                return(res);
            }
            catch (Exception)
            {
                throw;
            }
        }