public void ManagerRetrieveByIdTest() { const long managerId = 1; var manager = ManagerRepository.GetById(managerId); Assert.AreEqual(managerId, manager.Id); }
/// <summary> /// Get Person Name /// </summary> /// <param name="id"></param> /// <param name="personType"></param> /// <returns></returns> private static string GetPersonName(long id, PersonType personType) { string personName = string.Empty; switch (personType) { case PersonType.Customer: var customer = CustomerRepository.GetById(id); personName = customer.FullName; break; case PersonType.Employee: var employee = EmployeeRepository.GetById(id); personName = employee.FullName; break; case PersonType.Manager: var manager = ManagerRepository.GetById(id); personName = manager.FullName; break; case PersonType.SalesPerson: var salesPerson = SalesPersonRepository.GetById(id); personName = salesPerson.FullName; break; } return(personName); }
/// <summary> /// get manager by id /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <ViewResult <ManagerModel> > GetById(int id) { var result = new ViewResult <ManagerModel>(); try { var mananger = await _managerRepository.GetById(id); result.Data = mananger.ToManagerModel(); } catch (Exception ex) { result.Status = -1; result.Message = ex.Message; Logger.WriteErrorLog("ManagerService", "GetById", ex); } return(result); }
public Manager GetById(int ManagerId) { var Manager = ManagerRepository.GetById(ManagerId); if (Manager == null) { throw new BadRequestException(ErrorMessages.TrabajadorNoEncontrado); } return(Manager); }
public async Task <ActionResult <Manager> > Get(int id) { try { // Searching for record in the database var response = await _repository.GetById(id); return(response); } catch (Npgsql.PostgresException ex) { // Postgres threw an exception return(BadRequest(ex.Message.ToString())); } catch { // Unknown error return(NotFound("Manager record you are searching for does not exist or the URL is wrong")); } }
public async Task CreateOrderPdfAndSendEmail(string rootUrl, int managerId, OrderInfoModel model, Order order, string name, string isTripleEmail = null) { try { var manager = await _managerRepository.GetById(managerId); var orderAddr = model.ToOrderAddrModel(); var pdfModel = new PdfOrderModel() { RootUrl = rootUrl, TemplatePath = System.Configuration.ConfigurationManager.AppSettings["Template_JobOrder"], FileName = string.Format("order{0}", order.OrderCode), HeadContact = "PO Box 1111" + "<br>" + "Burswood WA 6100 " + "<br>" + "T (08) 9470 7300" + "<br>" + "F (08) 9362 6210" + "<br>" + "<br>" + "E [email protected]" + "<br>" + "www.datanet.com.au" + "<br>" + "<br>" + "ABN: 56 123 914 616", HeadDeliverTo = order.ContactName + (!string.IsNullOrEmpty(order.ContactName) ?"<br>":"") + order.CompanyName + (!string.IsNullOrEmpty(order.CompanyName) ? "<br>" : "") + orderAddr?.Addr1 + (!string.IsNullOrEmpty(orderAddr?.Addr1) ? "<br>" : "") + orderAddr?.Addr2 + (!string.IsNullOrEmpty(orderAddr?.Addr2) ? "<br>" : "") + orderAddr?.Addr3 + (!string.IsNullOrEmpty(orderAddr?.Addr3) ? "<br>" : "") + orderAddr?.State + " " + orderAddr?.PostCode, HeadOrderTo = order.CompanyName, HeadOrderDate = order.CreateTime?.AddHours(model.TimeZone).ToString("dd'/'MM'/'yyyy"), HeadRefNumber = order.OrderCode, HeadAccountManager = order.ManagerName + "<br>" + manager?.Phone + "<br>" + "<a href='mailto:" + manager?.Email + "'>" + manager?.Email + "</a>", SumSubTotal = (order.Amount - order.GST)?.ToString("c2", CulturesHelper.Australia), SumGst = order.GST?.ToString("c2", CulturesHelper.Australia), SumAmount = order.Amount?.ToString("c2", CulturesHelper.Australia), OrderDetailList = new List <PdfOrderDetailModel>() { } }; foreach (var productItem in model.OrderProducts) { var product = await _productRepository.GetById(productItem.ProductId); pdfModel.OrderDetailList.Add(new PdfOrderDetailModel() { StockCode = product.Code, Description = product.ShortDesc, Qty = productItem.Quantity.ToString() + ".00", UnitPrice = productItem.Price?.ToString("c2", CulturesHelper.Australia), LineTotal = ((productItem.Quantity * productItem.Price)?.ToString("c2", CulturesHelper.Australia)) }); } pdfModel.OrderDetailList.Add(new PdfOrderDetailModel() { StockCode = "DELIVERY", Description = "Delivery", Qty = "1.00", UnitPrice = model.DeliveryCharge.ToString("c2", CulturesHelper.Australia), LineTotal = model.DeliveryCharge.ToString("c2", CulturesHelper.Australia) }); order.PDFPath = PdfHelper.GetOrderPdfPath(pdfModel); await _orderRepositroy.AddOrUpdate(order); var sendEmailResult = await SendEmailById(order.Id, rootUrl, isTripleEmail); if (sendEmailResult.Status != 0) { throw new Exception(sendEmailResult.Message); } } catch (Exception ex) { //add order history var history = new OrderHistory { Id = 0, CreateTime = DateTime.UtcNow, CreateBy = name, TableName = "", FieldName = "", OldValue = "", NewValue = "", Note = Constants.OrderHistoryAddOrder, Operator = Constants.OrderHistoryErrorOperator, OrderId = order.Id }; await _orderHistoryRepository.AddOrUpdate(history); Logger.WriteErrorLogForOrder("OrderService", "CreateOrderPdfAndSendEmail", ex, order.Id); } }
/// <summary> /// Get Manager /// </summary> /// <param name="id"></param> /// <returns></returns> public ManagerDto Get(long id) { var manager = Mapper.DynamicMap <Manager, ManagerDto>(ManagerRepository.GetById(id)); return(manager); }
public void DeleteManager(int ManagerId) { var Manager = ManagerRepository.GetById(ManagerId); ManagerRepository.Delete(Manager); }