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; } }
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; } }
internal static async Task DeleteMSPLocationBranch(long Id, string type) { try { using (db = new eMSPEntities()) { tblMSPLocationBranch obj = new tblMSPLocationBranch(); switch (type) { case "Location": obj = await db.tblMSPLocationBranches.Where(a => a.LocationID == Id).SingleAsync(); break; case "Branch": obj = await db.tblMSPLocationBranches.Where(a => a.BranchID == Id).SingleAsync(); break; } db.tblMSPLocationBranches.Remove(obj); int x = await Task.Run(() => db.SaveChangesAsync()); } } catch (Exception) { throw; } }
public static LocationCreateModel ConvertToMSPLocationBranch(this tblMSPLocationBranch data) { return(new LocationCreateModel() { id = data.ID, companyId = data.MSPID, locationId = data.LocationID, branchId = data.BranchID, isActive = data.IsActive, isDeleted = data.IsDeleted, createdUserID = data.CreatedUserID, updatedUserID = data.UpdatedUserID, createdTimestamp = data.CreatedTimestamp, updatedTimestamp = data.UpdatedTimestamp }); }
internal static async Task <tblMSPLocationBranch> UpdateMSPLocationBranch(tblMSPLocationBranch model) { try { using (db = new eMSPEntities()) { db.Entry(model).State = EntityState.Modified; int x = await Task.Run(() => db.SaveChangesAsync()); return(model); } } catch (Exception) { throw; } }
internal static async Task <tblMSPLocationBranch> InsertMSPLocationBranch(tblMSPLocationBranch model) { try { using (db = new eMSPEntities()) { model = db.tblMSPLocationBranches.Add(model); int x = await Task.Run(() => db.SaveChangesAsync()); return(model); } } catch (Exception) { throw; } }