/// <summary> /// Delete a client from the DB /// </summary> /// <param name="client"></param> /// <returns></returns> public bool DeleteClient(Client client) { try { ClientsRepository.Instance.Delete(client); return true; } catch (Exception ex) { ProcessDBException(ex); mLogger.Log("DeleteClient Exception : " + ex.Message, Category.Exception, Priority.Medium); return false; } }
public override void Import(Worksheet worksheet) { int rowPosition = 2; while (!string.IsNullOrEmpty(worksheet.Cells[rowPosition, 1].Text)) { string agent = worksheet.Cells[rowPosition, 1].Text; string branch = worksheet.Cells[rowPosition, 2].Text; string invoiceAddressLine1 = worksheet.Cells[rowPosition, 4].Text; string invoiceAddressLine2 = worksheet.Cells[rowPosition, 5].Text; string town = worksheet.Cells[rowPosition, 6].Text; string county = worksheet.Cells[rowPosition, 7].Text; string postCode = worksheet.Cells[rowPosition, 8].Text; string priceListType = worksheet.Cells[rowPosition, 9].Text; string priceListURL = string.Empty; Hyperlinks links = worksheet.Cells[rowPosition, 9].Hyperlinks; if (links.Count > 0) { priceListURL = links[1].Address; } string additionalRooms = worksheet.Cells[rowPosition, 10].Text; string invoiceNotes = worksheet.Cells[rowPosition, 11].Text; string contactTelephone = worksheet.Cells[rowPosition, 12].Text; string checkinDistribution = worksheet.Cells[rowPosition, 13].Text; string checkOutDistribution = worksheet.Cells[rowPosition, 14].Text; string accountsContact = worksheet.Cells[rowPosition, 15].Text; string reviewContact = worksheet.Cells[rowPosition, 16].Text; string reviewType = worksheet.Cells[rowPosition, 17].Text; string reviewDate = worksheet.Cells[rowPosition, 18].Text; string notes = worksheet.Cells[rowPosition, 19].Text; // create the model object and persist it Client clientToImport = new Client() { Agent = agent, Branch = branch, AddressLine1 = invoiceAddressLine1, AddressLine2 = invoiceAddressLine2, Town = town, County = county, Postcode = postCode, PriceListURL = priceListURL, PricetListType = priceListType, AdditionalRooms = additionalRooms, InvoiceNotes = invoiceNotes, AccountsContact = accountsContact, AccountsContactTelephone = contactTelephone, CheckInDistribution = checkinDistribution, CheckOutDistribution = checkOutDistribution }; if (!string.IsNullOrEmpty(reviewContact) || !string.IsNullOrEmpty(reviewType) || !string.IsNullOrEmpty(notes)) { Review review = new Review() { Client = clientToImport, ReviewContact = reviewContact, ReviewType = reviewType, ReviewDate = ParseDateValue(reviewDate), Notes = notes }; clientToImport.Review = review; } // WARNING: review date is for the moment ignored, since no formatting details are available ClientsRepository.Instance.CreateOrUpdate(clientToImport); rowPosition++; } }