public bool CreateServiceOffer(Offer offer) { try { if (RegexMatch.DoesOfferMatch(offer) && (offer.RatePerHour > 0)) { var serviceOffer = _unitOfWork.Offers.Create(new ServiceOffer { SubCategory = new Repository.DbConnection.SubCategory { Name = offer.Subcategory.ToString(), Category = new Repository.DbConnection.Category { Name = offer.Category.ToString(), }, }, AvailabilityState = new AvailabilityState { State = "Active" }, Title = offer.Title, Description = offer.Description, RatePerHour = offer.RatePerHour, Employee_ID = offer.AuthorId, }); return(true); } else { return(false); } } catch { return(false); } }
public bool UpdateServiceOffer(Offer serviceOffer) { try { if (RegexMatch.DoesOfferMatch(serviceOffer) && (serviceOffer.RatePerHour > 0)) { _unitOfWork.Offers.Update(new ServiceOffer { ID = serviceOffer.Id, Description = serviceOffer.Description, Title = serviceOffer.Title, RatePerHour = serviceOffer.RatePerHour, SubCategory = new Repository.DbConnection.SubCategory { Name = serviceOffer.Subcategory.ToString(), Category = new Repository.DbConnection.Category { Name = serviceOffer.Category.ToString() } }, }); return(true); } return(false); } catch (ChangeConflictException e) { //optimistic concurrency throw e; } catch { return(false); } }