public static void UpdateBranchDetails(RentCarBranch updatebranch) { try { using (RentCarDatabaseEntities1 branchEntities = new RentCarDatabaseEntities1()) { var currentBranch = branchEntities.RentCarBranches.FirstOrDefault(c => c.id == updatebranch.id); currentBranch.branches = updatebranch.branches; currentBranch.address = updatebranch.address; currentBranch.latitude = updatebranch.latitude; currentBranch.longitude = updatebranch.longitude; currentBranch.status = updatebranch.status; branchEntities.SaveChanges(); } } catch (Exception serverException) { RentCarServerErrorsLog errorsLog = new RentCarServerErrorsLog(); errorsLog.ErrorMsg = serverException.ToString(); errorsLog.Date = DateTime.Now.ToString(); using (RentCarDatabaseEntities1 errorsEntities = new RentCarDatabaseEntities1()) { errorsEntities.RentCarServerErrorsLogs.Add(errorsLog); errorsEntities.SaveChanges(); } } }
public static void AddBranch(RentCarBranch newbranch) { try { using (RentCarDatabaseEntities1 branchEntities = new RentCarDatabaseEntities1()) { branchEntities.RentCarBranches.Add(newbranch); branchEntities.SaveChanges(); } } catch (Exception serverException) { RentCarServerErrorsLog errorsLog = new RentCarServerErrorsLog(); errorsLog.ErrorMsg = serverException.ToString(); errorsLog.Date = DateTime.Now.ToString(); using (RentCarDatabaseEntities1 errorsEntities = new RentCarDatabaseEntities1()) { errorsEntities.RentCarServerErrorsLogs.Add(errorsLog); errorsEntities.SaveChanges(); } } }
public static void DeleteBranchByName(int Id) { try { using (RentCarDatabaseEntities1 branchEntities = new RentCarDatabaseEntities1()) { RentCarBranch brc = branchEntities.RentCarBranches.FirstOrDefault(c => c.id == Id); branchEntities.RentCarBranches.Remove(brc); branchEntities.SaveChanges(); } } catch (Exception serverException) { RentCarServerErrorsLog errorsLog = new RentCarServerErrorsLog(); errorsLog.ErrorMsg = serverException.ToString(); errorsLog.Date = DateTime.Now.ToString(); using (RentCarDatabaseEntities1 errorsEntities = new RentCarDatabaseEntities1()) { errorsEntities.RentCarServerErrorsLogs.Add(errorsLog); errorsEntities.SaveChanges(); } } }
public void UpdateBranchDetails([FromBody] RentCarBranch updatebranch) { Branches.UpdateBranchDetails(updatebranch); }//update branch details
public void AddBranch([FromBody] RentCarBranch newbranch) { Branches.AddBranch(newbranch); }//add new branch