Example #1
0
        internal static async Task DeleteSupplierBranchLocation(long Id, string type)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    tblSupplierLocationBranch obj = new tblSupplierLocationBranch();
                    switch (type)
                    {
                    case "Location":
                        obj = await db.tblSupplierLocationBranches.Where(a => a.LocationID == Id).SingleAsync();

                        break;

                    case "Branch":
                        obj = await db.tblSupplierLocationBranches.Where(a => a.BranchID == Id).SingleAsync();

                        break;
                    }

                    db.tblSupplierLocationBranches.Remove(obj);
                    int x = await Task.Run(() => db.SaveChangesAsync());
                }
            }
            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;
            }
        }
 public static LocationCreateModel ConvertToSupplierLocationBranch(this tblSupplierLocationBranch data)
 {
     return(new LocationCreateModel()
     {
         id = data.ID,
         companyId = data.SupplierID,
         locationId = data.LocationID,
         branchId = data.BranchID,
         isActive = data.IsActive,
         isDeleted = data.IsDeleted,
         createdUserID = data.CreatedUserID,
         updatedUserID = data.UpdatedUserID,
         createdTimestamp = data.CreatedTimestamp,
         updatedTimestamp = data.UpdatedTimestamp
     });
 }
Example #5
0
        internal static async Task <tblSupplierLocationBranch> UpdateSupplierBranchLocation(tblSupplierLocationBranch model)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    db.Entry(model).State = EntityState.Modified;

                    int x = await Task.Run(() => db.SaveChangesAsync());

                    return(model);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #6
0
        internal static async Task <tblSupplierLocationBranch> InsertSupplierLocationBranch(tblSupplierLocationBranch model)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    model = db.tblSupplierLocationBranches.Add(model);

                    int x = await Task.Run(() => db.SaveChangesAsync());

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