public BookLog Delete(BookLog BookLog) { _logEntryService.DeleteEntriesFromBookLog(BookLog.Id); database.BookLog.Remove(BookLog); database.SaveChanges(); return(BookLog); }
public string GetBill(BookLog book) { var bill = ""; var hourInterval = book.TimeOut.Value.Subtract(book.TimeIn.Value); var dayInterval = book.DateOfDeparture.Value.Subtract(book.DateOfArrival.Value); switch (book.SpaceType) { case (int)SpaceEnum.OpenSpace: switch (book.FrequencyType) { case (int)FrequencyEnum.Hourly: bill = (hourInterval.Hours * 50).ToString(); return(bill); case (int)FrequencyEnum.Daily: bill = (dayInterval.Days * 300).ToString(); return(bill); case (int)FrequencyEnum.Weekly: var weeks = dayInterval.Days < 7 ? 1 : dayInterval.Days / 7; var days = dayInterval.Days < 7 ? 0 : dayInterval.Days % 7; weeks += weeks > 7 && days > 0 ? 1 : 0; bill = (weeks * 1200).ToString(); return(bill); default: return(""); } case (int)SpaceEnum.PrivateSpace: switch (book.FrequencyType) { case (int)FrequencyEnum.Hourly: bill = (hourInterval.Hours * 75).ToString(); return(bill); case (int)FrequencyEnum.Daily: bill = (dayInterval.Days * 350).ToString(); return(bill); case (int)FrequencyEnum.Weekly: var weeks = dayInterval.Days < 7 ? 1 : dayInterval.Days / 7; var days = dayInterval.Days < 7 ? 0 : dayInterval.Days % 7; weeks += weeks > 7 && days > 0 ? 1 : 0; bill = (weeks * 1500).ToString(); return(bill); default: return(""); } case (int)SpaceEnum.ConferenceMeeting: bill = (hourInterval.Hours * 300).ToString(); return(bill); default: return(""); } }
public string GetDuration(BookLog book) { string duration = ""; var hourInterval = book.TimeOut.Value.Subtract(book.TimeIn.Value); var dayInterval = book.DateOfDeparture.Value.Subtract(book.DateOfArrival.Value); switch (book.FrequencyType) { case (int)FrequencyEnum.Hourly: var hour = hourInterval.Hours; var minutes = hourInterval.Minutes; duration = hour + (hour == 1 ? " hour" : " hours") + (minutes > 0? (minutes == 1? " and " + minutes + " minute": " and " + minutes + " minutes") : ""); return(duration); case (int)FrequencyEnum.Daily: var day = dayInterval.Days; hour = hourInterval.Hours; duration = day + (day == 1 ? " day" : " days") + (hour > 0 ? (hour == 1 ? " and " + hour + " hour" : " and " + hour + " hours") : ""); return(duration); case (int)FrequencyEnum.Weekly: day = dayInterval.Days; var isWeek = day >= 7; var weeks = isWeek ? day / 7 : day; var days = isWeek ? dayInterval.Days % 7 : day; duration = isWeek ? weeks + (weeks > 1 ? " weeks" : " week") + (days > 0 ? (days == 1 ? " and " + days + " day" : " and " + days + " days") : "") : weeks > 1? weeks + " days" : " day"; return(duration); default: return(duration); } }
private async Task BorrowBookAsync(MobileBookOfficeLogsDto officeBookWithLogs, BookTakeDto bookDto) { var bookLog = new BookLog { ApplicationUserId = bookDto.ApplicationUserId, BookOfficeId = officeBookWithLogs.BookOfficeId, ModifiedBy = bookDto.ApplicationUserId, Modified = DateTime.UtcNow, TakenFrom = DateTime.UtcNow, Created = DateTime.UtcNow, CreatedBy = bookDto.ApplicationUserId, OrganizationId = bookDto.OrganizationId }; _bookLogsDbSet.Add(bookLog); await _uow.SaveChangesAsync(false); }
private void BorrowBook(MobileBookOfficeLogsDTO officeBookWithLogs, BookTakeDTO bookDTO) { var bookLog = new BookLog() { ApplicationUserId = bookDTO.ApplicationUserId, BookOfficeId = officeBookWithLogs.BookOfficeId, ModifiedBy = bookDTO.ApplicationUserId, Modified = DateTime.UtcNow, TakenFrom = DateTime.UtcNow, Created = DateTime.UtcNow, CreatedBy = bookDTO.ApplicationUserId, OrganizationId = bookDTO.OrganizationId, }; _bookLogsDbSet.Add(bookLog); _uow.SaveChanges(false); }
public IEnumerable <BookLog> GetAllBookLogs() { List <BookLog> bookLogs = new List <BookLog>(); using (OracleConnection connection = new OracleConnection(_connectionString)) { using (OracleCommand command = connection.CreateCommand()) { connection.Open(); command.BindByName = true; command.CommandText = "Select * From BOOK_LOG"; OracleDataReader reader = command.ExecuteReader(); while (reader.Read()) { BookLog bookLog = new BookLog { LogId = Convert.ToInt32(reader["LOG_ID"]), LogType = reader["LOG_TYPE"].ToString(), NewName = reader["NEW_NAME"].ToString(), NewWriter = reader["NEW_WRITER"].ToString(), NewPrice = reader["NEW_PRICE"].ToString(), NewStockAmount = reader["NEW_STOCK_AMOUNT"].ToString(), NewBarcode = reader["NEW_BARCODE"].ToString(), NewCategoryId = reader["NEW_CATEGORY_ID"].ToString(), OldName = reader["OLD_NAME"].ToString(), OldWriter = reader["OLD_WRITER"].ToString(), OldPrice = reader["OLD_PRICE"].ToString(), OldStockAmount = reader["OLD_STOCK_AMOUNT"].ToString(), OldBarcode = reader["OLD_BARCODE"].ToString(), OldCategoryId = reader["OLD_CATEGORY_ID"].ToString(), LogDate = reader["LOG_DATE"].ToString(), }; bookLogs.Add(bookLog); } } } return(bookLogs); }
public EmailParameters GetConfirmEmailParameter(BookLog book, bool isAdmin, ClientMaster client) { var bookDate = GetPeriod(book.DateOfArrival.Value, book.DateOfDeparture.Value, book.TimeIn.Value, book.TimeOut.Value); var duration = GetDuration(book); var bill = "₱" + GetBill(book); if (!isAdmin) { var emailParams = new EmailParameters() { Subject = $"Dev Hub: Book Confirmed!", Firstname = client.FirstName, Lastname = client.LastName, Email = client.Email, Space = GetSpaceName(book.SpaceType.Value), Recipient = client.Email, IsAdmin = false, Date = bookDate.DateArrival, Rate = GetBookRate(book.FrequencyType.Value, book.SpaceType.Value), Template = "Confirm-Booking-Template", ReferenceNumber = book.BookingRefCode, Time = bookDate.TimeIn, Period = bookDate.Period(), ContactNumber = client.ContactNumber1 + " , " + client.ContactNumber2, Duration = duration, Bill = bill }; switch (book.SpaceType) { case (int)SpaceEnum.ConferenceMeeting: emailParams.Template = "Confirm-Booking-Conference-Template"; return(emailParams); default: return(emailParams); } } else { return(null); } }
public void SendEmail(BookLog bookLog, MobileBookOfficeLogsDTO bookOffice) { var organizationName = _organizationsDbSet .Where(organization => organization.Id == bookLog.OrganizationId) .Select(organization => organization.ShortName) .FirstOrDefault(); var userEmail = _usersDbSet .Where(u => u.Id == bookLog.ApplicationUserId) .Select(u => u.Email) .First(); var subject = Resources.Models.Books.Books.EmailSubject; var userNotificationSettingsUrl = _appSettings.UserNotificationSettingsUrl(organizationName); var bookUrl = _appSettings.BookUrl(organizationName, bookOffice.BookOfficeId, bookOffice.OfficeId); var emailTemplateViewModel = new BookTakenEmailTemplateViewModel(userNotificationSettingsUrl, bookOffice.Title, bookOffice.Author, bookUrl); var body = _mailTemplate.Generate(emailTemplateViewModel, EmailTemplateCacheKeys.BookTaken); _mailingService.SendEmail(new EmailDto(userEmail, subject, body)); }