public bool ChangeContractStatus(int serviceId, int counterpartId, int serviceOwnerId, int?serviceOwnerStatus, int?counterpartStatus) { using (ServiceDBModel db = new ServiceDBModel()) try { ContractData acceptingContract = db.ContractData .Where(item => ( item.ServiceId == serviceId && item.CounterpartId == counterpartId && item.ServiceOwnerId == serviceOwnerId )) .FirstOrDefault(); if (serviceOwnerStatus != null) { acceptingContract.ServiceOwnerStatus = serviceOwnerStatus.GetValueOrDefault(); } if (counterpartStatus != null) { acceptingContract.CounterpartStatus = counterpartStatus.GetValueOrDefault(); } db.SaveChanges(); return(true); } catch (Exception) { Log.Error("Error"); return(false); } }
//Inte färdigt public bool CreateService( int type, int creatorId, int serviceStatusId, string picture, string title, string description, double price, DateTime?startDate, DateTime?endDate, bool timeNeeded, int subCategoryId ) { DateTime createdTime = DateTime.Now; ServiceData serviceData = new ServiceData(type, subCategoryId, creatorId, serviceStatusId, picture, createdTime, title, description, price, startDate, endDate, timeNeeded); using (ServiceDBModel db = new ServiceDBModel()) { try { db.ServiceData.Add(serviceData); db.SaveChanges(); return(true); } catch (Exception) { Log.Error("Error"); return(false); } } }
public bool DeleteCategory(int id) { using (ServiceDBModel db = new ServiceDBModel()) { try { CategoryData categoryToRemove = db.CategoryData.Find(id); db.CategoryData.Remove(categoryToRemove); db.SaveChanges(); return(true); } catch (Exception) { Log.Error("Error"); return(false); } } }
public bool EditCategory(int id, string title) { using (ServiceDBModel db = new ServiceDBModel()) { try { CategoryData categoryData = db.CategoryData.Find(id); categoryData.Titel = title; db.SaveChanges(); return(true); } catch (Exception) { Log.Error("Error"); return(false); } } }
public bool DeleteService(int id) { using (ServiceDBModel db = new ServiceDBModel()) { try { ServiceData foundService = db.ServiceData.Find(id); db.ServiceData.Remove(foundService); db.SaveChanges(); return(true); } catch (Exception) { Log.Error("Error"); return(false); } } }
public bool CreateCategory(string title) { using (ServiceDBModel db = new ServiceDBModel()) { try { CategoryData categoryData = new CategoryData(); categoryData.Titel = title; db.CategoryData.Add(categoryData); db.SaveChanges(); return(true); } catch (Exception) { Log.Error("Error"); return(false); } } }
public bool CreateSubCategory(int parentId, string title) { using (ServiceDBModel db = new ServiceDBModel()) { try { SubCategoryData subCategoryData = new SubCategoryData(); subCategoryData.Parent = parentId; subCategoryData.Titel = title; db.SubCategoryData.Add(subCategoryData); db.SaveChanges(); return(true); } catch (Exception) { Log.Error("Error"); return(false); } } }
public bool CreateContract(int serviceId, int counterpartId, int serviceOwnerId, int contractCreatorId) { int serviceOwnerStatus = 0; int counterpartStatus = 0; if (serviceOwnerId == contractCreatorId) { serviceOwnerStatus = 1; } else if (counterpartId == contractCreatorId) { counterpartStatus = 1; } else if (counterpartId != contractCreatorId && serviceOwnerId != contractCreatorId) { return(false); } using (ServiceDBModel db = new ServiceDBModel()) { try { ContractData creatingContract = new ContractData(); creatingContract.ServiceId = serviceId; creatingContract.ServiceOwnerId = serviceOwnerId; creatingContract.CounterpartId = counterpartId; creatingContract.CounterpartStatus = counterpartStatus; creatingContract.ServiceOwnerStatus = serviceOwnerStatus; db.ContractData.Add(creatingContract); db.SaveChanges(); return(true); } catch (Exception) { Log.Error("Error"); return(false); } } }
public bool EditService( int id, int type, int serviceStatusId, string picture, string title, string description, double price, DateTime?startDate, DateTime?endDate, bool timeNeeded, int subCategoryId) { using (ServiceDBModel db = new ServiceDBModel()) { try { ServiceData foundService = db.ServiceData.Find(id); foundService.Type = type; foundService.ServiceStatusID = serviceStatusId; foundService.Picture = picture; foundService.Title = title; foundService.Description = description; foundService.Price = price; foundService.StartDate = startDate; foundService.EndDate = endDate; foundService.TimeNeeded = timeNeeded; foundService.Category = subCategoryId; db.SaveChanges(); return(true); } catch (Exception) { Log.Error("Error"); return(false); } } }
public bool DeleteContract(int serviceId, int counterpartId, int serviceOwnerId) { using (ServiceDBModel db = new ServiceDBModel()) try { ContractData deleteContract = db.ContractData.Where(item => ( item.ServiceId == serviceId && item.CounterpartId == counterpartId && item.ServiceOwnerId == serviceOwnerId )) .FirstOrDefault(); db.ContractData.Remove(deleteContract); db.SaveChanges(); return(true); } catch (Exception) { Log.Error("Error"); return(false); } }