public async Task <UpdateUserDto> UpdateAccount(string userid, UpdateUserDto model) { var user = await TheUnitOfWork.AccountRepo.FindById(userid); if (user != null) { if (user.IsDoctor) { var doctor = TheUnitOfWork.DoctorRepo.GetById(userid); doctor.doctorInfo = model.DoctorInfo; doctor.TitleDegree = model.TitleDgree; doctor.specialtyId = model.SpecialtyId ?? doctor.specialtyId; var result = TheUnitOfWork.SaveChanges(); if (result < new int()) { return(null); } } user.FullName = model.FullName; user.Email = model.Email; user.PhoneNumber = model.PhoneNumber; await TheUnitOfWork.AccountRepo.UpdateAccount(user); return(model); } return(null); }
public void Insert(CategoryViewModel categoryViewModel) { var category = Mapper.Map <Category>(categoryViewModel); TheUnitOfWork.Category.Insert(category); TheUnitOfWork.Commit(); }
public bool AssignColorToProduct(Product product, int colorId) { Color color = TheUnitOfWork.Color.GetById(colorId); TheUnitOfWork.Product.AssignColorToProduct(product, color); return(TheUnitOfWork.Commit() > new int()); }
internal void DecreaseQuantity(int Id, int quantity) { Product product = GetById(Id); product.Quantity -= quantity; TheUnitOfWork.Commit(); }
public async Task <bool> ResetPasswordAsync(ResetPasswordDTO model) { var result = await TheUnitOfWork.AccountRepo.ResetPasswordAsync(model); TheUnitOfWork.SaveChanges(); return(result); }
public void MakeOrder(string userId, IEnumerable <CartProduct> cartProducts) { // make orderHeader and add it to the user OrderHeader orderHeader = new OrderHeader() { OrderDate = DateTime.Now }; userAppService.checkout(userId, orderHeader); // every product have order details foreach (var carProduct in cartProducts) { OrderDetails orderDetails = new OrderDetails() { Quantity = carProduct.Quantity, OrderDate = DateTime.Now, TotalPrice = carProduct.getTotalPrice(), ProductID = carProduct.Product.ID, OrderID = orderHeader.ID }; orderDetailsAppService.Insert(orderDetails); AddOrderDetails(orderHeader.ID, orderDetails); productAppService.DecreaseQuantity(carProduct.Product.ID, carProduct.Quantity); } TheUnitOfWork.Commit(); }
public void EmptyCart(string userId) { var user = FindByID(userId); user.Cart.CartProducts = null; TheUnitOfWork.Commit(); }
public bool UpdateEmployee(ApplicationUserIdentity employee) { TheUnitOfWork.Account.Update(employee); TheUnitOfWork.Commit(); return(true); }
public void DeleteList(IEnumerable <GetWorkingDayDTO> workingDaysDTOs) { var workingDays = Mapper.Map <IEnumerable <WorkingDay> >(workingDaysDTOs); TheUnitOfWork.WorkingDayRepo.DeleteList(workingDays); TheUnitOfWork.SaveChanges(); }
public void Insert(ColorViewModel ColorViewModel) { var color = Mapper.Map <Color>(ColorViewModel); TheUnitOfWork.Color.Insert(color); TheUnitOfWork.Commit(); }
public void UpdateQuantity(string cartId, int productId, int quantity) { CartProduct cartProduct = GetCartProduct(cartId, productId); cartProduct.Quantity = quantity; TheUnitOfWork.Commit(); }
public async Task CreateRoles() { await TheUnitOfWork.RoleRepo.CreateRoles(); TheUnitOfWork.SaveChanges(); TheUnitOfWork.CommitTransaction(); }
public bool UpdateAppointment(Appointment appointment) { TheUnitOfWork.Appointment.Update(appointment); TheUnitOfWork.Commit(); return(true); }
public bool Update(OrderHeader OrderHeader) { TheUnitOfWork.OrderHeader.Update(OrderHeader); TheUnitOfWork.Commit(); return(true); }
public bool UpdateDealer(Dealer dealer) { TheUnitOfWork.Dealer.Update(dealer); TheUnitOfWork.Commit(); return(true); }
public bool Update(OrderDetails OrderDetails) { TheUnitOfWork.OrderDetails.Update(OrderDetails); TheUnitOfWork.Commit(); return(true); }
public void Insert(AddProductVM ProductViewModel) { var product = Mapper.Map <Product>(ProductViewModel); TheUnitOfWork.Product.Insert(product); TheUnitOfWork.Commit(); }
private void AddOrderDetails(int orderHeaderId, OrderDetails orderDetails) { OrderHeader orderHeader = GetByID(orderHeaderId); orderHeader.AddOrder(orderDetails); TheUnitOfWork.Commit(); }
public CreateRatingDto Insert(CreateRatingDto rateDto) { if (rateDto == null) { throw new ArgumentNullException(); } var reserve = TheUnitOfWork.ReservationRepo.GetById(rateDto.ReservationId); reserve.IsRated = true; TheUnitOfWork.ReservationRepo.Update(reserve); var doctor = TheUnitOfWork.DoctorRepo.GetById(reserve.doctorId); doctor.CountOfRating++; doctor.SumOfRating += rateDto.Rate; doctor.AverageRate = doctor.SumOfRating / doctor.CountOfRating; TheUnitOfWork.DoctorRepo.Update(doctor); rateDto.DoctorId = reserve.doctorId; Rating Rate = Mapper.Map <Rating>(rateDto); TheUnitOfWork.RatingRepo.Insert(Rate); TheUnitOfWork.SaveChanges(); return(rateDto); }
public bool UpdateNotification(Notification notification) { TheUnitOfWork.Notification.Update(notification); TheUnitOfWork.Commit(); return(true); }
public CreateOfferRatingDto Insert(CreateOfferRatingDto rateDto) { if (rateDto == null) { throw new ArgumentNullException(); } var ReserveOffer = TheUnitOfWork.ReserveOfferRepo.GetById(rateDto.ReserveOfferId); var doctorOffer = TheUnitOfWork.MakeOfferRepo.GetById(ReserveOffer.MakeOfferId); doctorOffer.CountOfRating++; doctorOffer.SumOfRating += rateDto.Rate; doctorOffer.AverageRate = doctorOffer.SumOfRating / doctorOffer.CountOfRating; TheUnitOfWork.MakeOfferRepo.Update(doctorOffer); ReserveOffer.IsRated = true; TheUnitOfWork.ReserveOfferRepo.Update(ReserveOffer); rateDto.MakeOfferId = ReserveOffer.MakeOfferId; OfferRating Rate = Mapper.Map <OfferRating>(rateDto); TheUnitOfWork.OfferRatingRepo.Insert(Rate); TheUnitOfWork.SaveChanges(); return(rateDto); }
public DayShift Insert(CreateDayShiftDTO createDayShiftDTO) { DayShift dayShift = Mapper.Map <DayShift>(createDayShiftDTO); var result = TheUnitOfWork.DayShiftRepo.Insert(dayShift); TheUnitOfWork.SaveChanges(); return(result); }
public bool UpdateProduct(ProductViewModel productViewModel) { var product = Mapper.Map <Product>(productViewModel); TheUnitOfWork.Product.Update(product); TheUnitOfWork.Commit(); return(true); }
public bool DeleteProductCart(int id) { bool result = false; TheUnitOfWork.ProductCart.Delete(id); result = TheUnitOfWork.Commit() > new int(); return(result); }
public List <ClinicServiceDto> InsertList(List <ClinicServiceDto> clinicServiceDtos) { List <Clinicservice> clinicservices = Mapper.Map <List <Clinicservice> >(clinicServiceDtos); TheUnitOfWork.ClincServicesRepo.InsertList(clinicservices); TheUnitOfWork.SaveChanges(); return(Mapper.Map <List <ClinicServiceDto> >(clinicservices)); }
public bool Delete(int id) { bool result = false; TheUnitOfWork.ClincServicesRepo.Delete(id); result = TheUnitOfWork.SaveChanges() > new int(); return(result); }
public bool UpdateCategroy(CategroyViewModel categroyViewModel) { var category = Mapper.Map <Category>(categroyViewModel); TheUnitOfWork.Category.Update(category); TheUnitOfWork.Commit(); return(true); }
public bool Delete(int id) { bool result = false; TheUnitOfWork.SpecialtyRepo.Delete(id); result = TheUnitOfWork.SaveChanges() > new int(); return(result); }
public void updateReservation(CreateReservationDTO createDto) { createDto.Date = createDto.Date.Date; Reservation reservation = Mapper.Map <Reservation>(createDto); TheUnitOfWork.ReservationRepo.Update(reservation); TheUnitOfWork.SaveChanges(); }
public void removeProduct(string userId, int productId) { Cart cart = TheUnitOfWork.Cart.GetById(userId); CartProduct cartProduct = TheUnitOfWork.CartProduct.GetCartProduct(cart.ID, productId); cart.CartProducts.Remove(cartProduct); TheUnitOfWork.Commit(); }