Ejemplo n.º 1
0
        internal static async Task DeleteCustomerLocationBranch(long Id, string type)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    tblCustomerLocationBranch obj = new tblCustomerLocationBranch();
                    switch (type)
                    {
                    case "Location":
                        obj = await db.tblCustomerLocationBranches.Where(a => a.LocationID == Id).SingleAsync();

                        break;

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

                        break;
                    }
                    db.tblCustomerLocationBranches.Remove(obj);
                    int x = await Task.Run(() => db.SaveChangesAsync());
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 4
0
 public static LocationCreateModel ConvertToCustomerLocationBranch(this tblCustomerLocationBranch data)
 {
     return(new LocationCreateModel()
     {
         id = data.ID,
         companyId = data.CustomerID,
         locationId = data.LocationID,
         locationName = data.tblLocation != null ? data.tblLocation.LocationName : "",
         branchId = data.BranchID,
         isActive = data.IsActive,
         isDeleted = data.IsDeleted,
         createdUserID = data.CreatedUserID,
         updatedUserID = data.UpdatedUserID,
         createdTimestamp = data.CreatedTimestamp,
         updatedTimestamp = data.UpdatedTimestamp
     });
 }
Ejemplo n.º 5
0
        internal static async Task <tblCustomerLocationBranch> UpdateCustomerLocationBranch(tblCustomerLocationBranch model)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    db.Entry(model).State = EntityState.Modified;

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

                    return(model);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 6
0
        internal static async Task <tblCustomerLocationBranch> InsertCustomerLocationBranch(tblCustomerLocationBranch model)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    model = db.tblCustomerLocationBranches.Add(model);

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

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