public OrderStatus DeleteOrder(Order order, string updatingUserId) { var daoOrder = ObjectFactory.CreateInstanceAndMap <Order, DaoOrder>(_iCommonMapper, order); daoOrder = _iOrderRepository.DeleteOrder(daoOrder, updatingUserId); return(ObjectFactory.CreateInstanceAndMap <DaoOrder, OrderStatus>(_iCommonMapper, daoOrder)); }
public void Can_Map_DomainOrder_To_DaoOrder() { //*** Arrange *** #region *** building xml *** var order = new DomainOrder { ExternalCompanyId = "333333", //requiared by database ExternalOrderId = Guid.NewGuid().ToString(), Priority = 1, //required by database ProvisionDate = DateTime.Now, CreatedByUser = "******", ModifiedByUser = "******", DateCreated = DateTime.Now, DateModified = DateTime.Now, Version = 1, StatusType = ANDP.Lib.Domain.Models.StatusType.Pending, ActionType = ActionType.Add, Account = new Account { Name = "Brent", Contact = new Contact { Address = new Address { Attention = "", }, } } }; #endregion //*** Act *** var daoOrder = ObjectFactory.CreateInstanceAndMap <DomainOrder, DaoOrder>(_commonMapper, order); Assert.IsNotNull(daoOrder); daoOrder.StatusTypeId = (int)StatusTypeEnum.Pending; var mappedDomainOrder = ObjectFactory.CreateInstanceAndMap <DaoOrder, DomainOrder>(_commonMapper, daoOrder); Assert.IsNotNull(mappedDomainOrder); }
public OrderStatus CreateOrUpdateOrder(Order order, string updatingUserId) { int companyId = RetrieveCompanyIdByExtCompanyId(order.ExternalCompanyId); //On a update or create we want to make sure a few columns do have data. order.Log = ""; order.ResultMessage = ""; order.ResponseSent = false; order.StartDate = null; order.CompletionDate = null; order.Validate(new CustomValidationService(_iOrderRepository, companyId)); if (order.ValidationErrors.Any()) { string errors = order.ValidationErrors.Aggregate("", (current, error) => current + (error + Environment.NewLine)); throw new Exception("Order Creation Failed:" + Environment.NewLine + errors); } var daoOrder = ObjectFactory.CreateInstanceAndMap <Order, DaoOrder>(_iCommonMapper, order); daoOrder = _iOrderRepository.CreateOrUpdateOrder(daoOrder, updatingUserId); return(ObjectFactory.CreateInstanceAndMap <DaoOrder, OrderStatus>(_iCommonMapper, daoOrder)); }
public OrderStatus UpdateOrder(Order order, string updatingUserId) { int companyId = RetrieveCompanyIdByExtCompanyId(order.ExternalCompanyId); order.Validate(new CustomValidationService(_iOrderRepository, companyId)); if (order.ValidationErrors.Any()) { string errors = order.ValidationErrors.Aggregate("", (current, error) => current + (error + Environment.NewLine)); throw new Exception("Update Failed:" + Environment.NewLine + errors); } //todo: quick fix to set these properties as when a order comes in end user doesn't want to have to set all this. //the attach should look for child objects. foreach (var service in order.Services) { service.CreatedByUser = updatingUserId; service.ModifiedByUser = updatingUserId; service.DateCreated = DateTime.Now; service.DateModified = DateTime.Now; //service.Version = 0; foreach (var location in service.Locations) { if (location.InternetItems != null) { foreach (var item in location.InternetItems) { item.CreatedByUser = updatingUserId; item.ModifiedByUser = updatingUserId; item.DateCreated = DateTime.Now; item.DateModified = DateTime.Now; //item.Version = 0; } } if (location.PhoneItems != null) { foreach (var item in location.PhoneItems) { item.CreatedByUser = updatingUserId; item.ModifiedByUser = updatingUserId; item.DateCreated = DateTime.Now; item.DateModified = DateTime.Now; //item.Version = 0; } } if (location.VideoItems != null) { foreach (var item in location.VideoItems) { item.CreatedByUser = updatingUserId; item.ModifiedByUser = updatingUserId; item.DateCreated = DateTime.Now; item.DateModified = DateTime.Now; //item.Version = 0; } } } } var daoOrder = ObjectFactory.CreateInstanceAndMap <Order, DaoOrder>(_iCommonMapper, order); daoOrder = _iOrderRepository.UpdateOrder(daoOrder, updatingUserId); return(ObjectFactory.CreateInstanceAndMap <DaoOrder, OrderStatus>(_iCommonMapper, daoOrder)); }
public void Can_Provision_Order() { Order order = new Order { Account = new Account { CompanyId = 7, ExternalAccountId = "myExternalAccountId", Contact = new Contact { Address = null, FirstName = "billy", LastName = "bob", PhoneNumber = "6541231234", Type = "mytype" }, StatusType = StatusType.Pending, CreatedByUser = "******", ModifiedByUser = "******" }, ActionType = ActionType.Add, CSR = null, ClassOfService = "myclass", CompletionDate = DateTime.Now, Configuration = "myConfiguration", CreatedByUser = "******", DateCreated = DateTime.Now, DateModified = DateTime.Now, ExternalAccountId = "s6767d96s78d", ExternalCompanyId = "4", ExternalOrderId = "4664984964678", Id = 0, Log = null, ModifiedByUser = "******", NewNetCaseId = null, NewNetProcessId = null, NewNetRouteIndex = null, NewNetTaskId = null, NewNetTriggerId = null, NewNetUserId = null, OrginatingIp = null, Priority = 1, Product = null, ProvisionDate = DateTime.Now, ResponseSent = false, ResultMessage = null, ServiceProvider = null, Services = new List <Service> { new Service { ActionType = ActionType.Add, CompletionDate = null, CreatedByUser = "******", DateCreated = DateTime.Now, DateModified = DateTime.Now, ExternalServiceId = "ExternalServiceId", Id = 0, Locations = new List <Location> { new Location { Address = new Address { }, CountyJurisdiction = null, DistrictJurisdiction = null, ExternalLocationId = null, LocationInfo = null, MsaGesn = 0, MsagExchange = null, TaxArea = null, ValidationErrors = null, //InternetItems = null, //VideoItems = new List<VideoItem> //{ // new VideoItem // { // StatusType = StatusType.Pending // } //}, PhoneItems = new List <PhoneItem> { new PhoneItem { ActionType = ActionType.Add, CompletionDate = null, CreatedByUser = "******", DateCreated = DateTime.Now, DateModified = DateTime.Now, Directory = null, ExternalItemId = "ExternalItemId", Id = 0, Log = null, ModifiedByUser = "******", ServiceId = 0, ResultMessage = null, StartDate = DateTime.Now, ValidationErrors = null, Version = 0, Xml = null, Priority = 1, ProvisionDate = DateTime.Now, StatusType = StatusType.Pending, //Features = null, LineInformation = new LineInformation { ActionType = ActionType.Add, PhoneNumber = "6541231234", InterLataPic = new InterLataPic { ActionType = ActionType.Add, Cic = "123", PicEffectiveDate = DateTime.Now }, IntraLataPic = new IntraLataPic { ActionType = ActionType.Add, Cic = "123", PicEffectiveDate = DateTime.Now }, InterNationalPic = new InterNationalPic { ActionType = ActionType.Add, Cic = "123", PicEffectiveDate = DateTime.Now } }, ProvisionSequence = 1 } } } }, Log = null, ModifiedByUser = "******", OrderId = 0, Priority = 1, ProvisionDate = DateTime.Now, ProvisionSequence = 1, ResultMessage = null, StartDate = DateTime.Now, StatusType = StatusType.Pending, ValidationErrors = null, Version = 0, Xml = null } }, StartDate = DateTime.Now, StatusType = StatusType.Pending, ValidationErrors = null, Version = 0, Xml = null }; order.Services[0].Locations[0].PhoneItems[0].Plant = new SerializableDictionary <string, object>(); var accessDevice = new SerializableDictionary <string, object> { { "AccessLine", 484 }, { "Name", "C024" } }; order.Services[0].Locations[0].PhoneItems[0].Plant.Add("AccessDevice", accessDevice); string json = JsonConvert.SerializeObject(order); var orderStatus = _iOrderService.CreateOrUpdateOrder(order, "hi"); //Assert.AreEqual(orderStatus.Id, 0); }
public void Can_Provision_Emp_Order() { Order order = new Order { Account = new Account { CompanyId = 7, ExternalAccountId = "myExternalAccountId", Contact = new Contact { Address = null, FirstName = "billy", LastName = "bob", PhoneNumber = "6541231234", Type = "mytype" }, StatusType = StatusType.Pending, CreatedByUser = "******", ModifiedByUser = "******" }, ActionType = ActionType.Add, CSR = null, ClassOfService = "myclass", CompletionDate = DateTime.Now, Configuration = "myConfiguration", CreatedByUser = "******", DateCreated = DateTime.Now, DateModified = DateTime.Now, ExternalAccountId = "s6767d96s78d", ExternalCompanyId = "4", ExternalOrderId = "4664984964678", Id = 0, Log = null, ModifiedByUser = "******", NewNetCaseId = null, NewNetProcessId = null, NewNetRouteIndex = null, NewNetTaskId = null, NewNetTriggerId = null, NewNetUserId = null, OrginatingIp = null, Priority = 1, Product = null, ProvisionDate = DateTime.Now, ResponseSent = false, ResultMessage = null, ServiceProvider = null, Services = new List <Service> { new Service { ActionType = ActionType.Add, CompletionDate = null, CreatedByUser = "******", DateCreated = DateTime.Now, DateModified = DateTime.Now, ExternalServiceId = "ExternalServiceId", Id = 0, Locations = new List <Location> { new Location { CountyJurisdiction = null, DistrictJurisdiction = null, ExternalLocationId = null, LocationInfo = null, MsaGesn = 0, MsagExchange = null, TaxArea = null, ValidationErrors = null, InternetItems = new List <InternetItem> { new InternetItem { Plant = new SerializableDictionary <string, object> { { "CentralOffice", "CalixE7" }, { "TransportType", "GPON" }, { "OntNumber", 5499100 }, { "Coid", "RSVL" }, { "Ports", new List <object> { new SerializableDictionary <string, object> { { "Name", "" }, { "Number", 5 }, { "Status", "" }, { "DataServiceNumber", 1 }, { "Type", "Ont" } } } } } } } } }, Log = null, ModifiedByUser = "******", OrderId = 0, Priority = 1, ProvisionDate = DateTime.Now, ProvisionSequence = 1, ResultMessage = null, StartDate = DateTime.Now, StatusType = StatusType.Pending, ValidationErrors = null, Version = 0, Xml = null } }, StartDate = DateTime.Now, StatusType = StatusType.Pending, ValidationErrors = null, Version = 0, Xml = null }; string json = JsonConvert.SerializeObject(order); //var doc = new XmlDocument(); //doc.LoadXml(xml); //string jsonText = JsonConvert.SerializeXmlNode(doc); //var orderStatus = _iOrderService.CreateOrUpdateOrder(order, "hi"); //Assert.IsNotNull(json); //Assert.AreEqual(orderStatus.Id, 0); }
public void Can_Delete_Order_By_Ext_Order_Id() { var externalOrderId = Guid.NewGuid().ToString(); //*** Arrange *** #region Building domain order model var order = new DomainOrder { ExternalOrderId = externalOrderId, ExternalCompanyId = "3", //required by database ExternalAccountId = Guid.NewGuid().ToString(), //required by the database Priority = 1, //required by database ProvisionDate = DateTime.Now, CreatedByUser = "******", ModifiedByUser = "******", DateCreated = DateTime.Now, DateModified = DateTime.Now, Version = 0, StatusType = StatusType.Pending, ActionType = ActionType.Add, Services = new List <Service> { new Service { CreatedByUser = "******", DateCreated = DateTime.Now, DateModified = DateTime.Now, ExternalServiceId = "3333", ModifiedByUser = "******", Priority = 1, ProvisionDate = DateTime.Now, ProvisionSequence = 1, Version = 0, StatusType = StatusType.Pending, ActionType = ActionType.Add, Locations = new List <Location> { new Location { Address = new Address { Attention = "hi" } } } } }, Account = new DomainAccount { Name = "Brent", CreatedByUser = "******", ModifiedByUser = "******", Contact = new Contact { Address = new Address { Attention = "" } } } }; #endregion var daoOrder = ObjectFactory.CreateInstanceAndMap <ANDP.Lib.Domain.Models.Order, ANDP.Lib.Data.Repositories.Order.Order>(_commonMapper, order); var initialOrderStatus = _iOrderRepository.CreateOrUpdateOrder(daoOrder, "UnitTest"); //Making sure we have a order created to delete. Assert.IsNotNull(initialOrderStatus); Assert.IsNotNull(initialOrderStatus.Id); Assert.AreNotEqual(0, initialOrderStatus.Id); Assert.IsNotNull(initialOrderStatus.ExternalOrderId); //*** Act *** var deleteOrderResult = _iOrderRepository.DeleteOrderByExtId(externalOrderId, ""); //*** Assert *** Assert.IsNull(deleteOrderResult); }
public void Can_Create_Order_Add_Phone_And_Video() { //*** Arrange *** #region Building domain order model string externalAccountId = Guid.NewGuid().ToString(); var order = new DomainOrder { ExternalOrderId = Guid.NewGuid().ToString(), ExternalCompanyId = "3", //required by database ExternalAccountId = externalAccountId, Priority = 1, //required by database ProvisionDate = DateTime.Now, CreatedByUser = "******", ModifiedByUser = "******", DateCreated = DateTime.Now, DateModified = DateTime.Now, Version = 0, ActionType = ANDP.Lib.Domain.Models.ActionType.Add, StatusType = StatusType.Pending, NewNetCaseId = "30194091753e4244f75eb34087632097", NewNetRouteIndex = "2", NewNetProcessId = "1", NewNetTaskId = "1", NewNetUserId = "1", Services = new List <Service> { new Service { CreatedByUser = "******", DateCreated = DateTime.Now, DateModified = DateTime.Now, ExternalServiceId = Guid.NewGuid().ToString(), ModifiedByUser = "******", Priority = 1, ProvisionDate = DateTime.Now, ProvisionSequence = 1, Version = 0, StatusType = StatusType.Pending, ActionType = ActionType.Add, Locations = new List <Location> { new Location { Address = new Address { Attention = "hi" }, VideoItems = new List <VideoItem> { new VideoItem { CreatedByUser = "******", DateCreated = DateTime.Now, DateModified = DateTime.Now, ExternalItemId = Guid.NewGuid().ToString(), ModifiedByUser = "******", Priority = 1, ProvisionDate = DateTime.Now, ProvisionSequence = 1, Version = 0, ActionType = ActionType.Add, StatusType = StatusType.Pending, Plant = new SerializableDictionary <string, object> { { "Settops", new List <object> { new SerializableDictionary <string, object> { { "Name", "DVR" }, { "Number", 5 }, { "Status", "" }, { "DataServiceNumber", 1 }, { "Type", "RCA" } } } } }, Features = new List <Feature> { new Feature { ActionType = ActionType.Add, Code = "HBO", Description = "HBO" }, new Feature { ActionType = ActionType.Add, Code = "Starz", Description = "Starz" } } } }, PhoneItems = new List <PhoneItem> { new PhoneItem { CreatedByUser = "******", DateCreated = DateTime.Now, DateModified = DateTime.Now, ExternalItemId = Guid.NewGuid().ToString(), ModifiedByUser = "******", Priority = 1, ProvisionDate = DateTime.Now, ProvisionSequence = 1, Version = 0, ActionType = ActionType.Add, StatusType = StatusType.Pending, LineInformation = new LineInformation { ActionType = ActionType.Add, PhoneNumber = "6051119999", CallerName = "QS Solutions", DirectoryPublish = "Yes" }, Features = new List <Feature> { new Feature { ActionType = ActionType.Add, Code = "VoiceMail", Description = "Gold Voice mail" } } } } } } } }, Account = new DomainAccount { Name = "Brent", CreatedByUser = "******", ModifiedByUser = "******", ExternalAccountId = externalAccountId, ExternalAccountGroupId = "test", Contact = new Contact { Address = new Address { Attention = "", } } } }; #endregion try { var daoOrder = ObjectFactory.CreateInstanceAndMap <ANDP.Lib.Domain.Models.Order, ANDP.Lib.Data.Repositories.Order.Order>(_commonMapper, order); //*** Act *** var newDomainOrder = _iOrderRepository.CreateOrUpdateOrder(daoOrder, "UnitTest"); //*** Assert *** Assert.IsNotNull(newDomainOrder); Assert.IsNotNull(newDomainOrder.Id); Assert.AreNotEqual(0, newDomainOrder.Id); } catch (Exception ex) { var t = ex.ToString(); throw; } }
public void Can_Create_Delete_Voicemail_Order() { //*** Arrange *** #region Building domain order model var order = new DomainOrder { ExternalOrderId = Guid.NewGuid().ToString(), ExternalCompanyId = "3", ExternalAccountId = Guid.NewGuid().ToString(), Priority = 1, //required by database ProvisionDate = DateTime.Now, //CreatedByUser = "******", //ModifiedByUser = "******", //DateCreated = DateTime.Now, //DateModified = DateTime.Now, //Version = 0, ActionType = ActionType.Change, StatusType = StatusType.Pending, NewNetCaseId = "30194091753e4244f75eb34087632097", NewNetRouteIndex = "1", NewNetProcessId = "1", NewNetTaskId = "1", NewNetUserId = "1", Services = new List <Service> { new Service { CreatedByUser = "******", DateCreated = DateTime.Now, DateModified = DateTime.Now, ExternalServiceId = Guid.NewGuid().ToString(), ModifiedByUser = "******", Priority = 1, ProvisionDate = DateTime.Now, ProvisionSequence = 1, //Version = 0, StatusType = StatusType.Pending, ActionType = ActionType.Change, Locations = new List <Location> { new Location { Address = new Address { Attention = "UnitTest", Municipality = "Sioux Falls", PostalCode = "57064", StreetLine1 = "111 S Some Street" }, PhoneItems = new List <PhoneItem> { new PhoneItem { ExternalItemId = Guid.NewGuid().ToString(), ActionType = ActionType.Change, StatusType = StatusType.Pending, CreatedByUser = "******", ModifiedByUser = "******", DateCreated = DateTime.Now, DateModified = DateTime.Now, LineInformation = new LineInformation { ActionType = ActionType.Unchanged, PhoneNumber = "6051119999", CallerName = "QS Solutions", DirectoryPublish = "Yes" }, Features = new List <Feature> { new Feature { ActionType = ActionType.Delete, Code = "VoiceMail", Description = "Gold Voice mail" } } } } } } } }, Account = new DomainAccount { Name = "Brent", //CreatedByUser = "******", //ModifiedByUser = "******", Contact = new Contact { Address = new Address { Attention = "UnitTest", Municipality = "Sioux Falls", PostalCode = "57064", StreetLine1 = "111 S Some Street" } } } }; #endregion var daoOrder = ObjectFactory.CreateInstanceAndMap <ANDP.Lib.Domain.Models.Order, ANDP.Lib.Data.Repositories.Order.Order>(_commonMapper, order); //*** Act *** var newDomainOrder = _iOrderRepository.CreateOrUpdateOrder(daoOrder, "UnitTest"); //*** Assert *** Assert.IsNotNull(newDomainOrder); Assert.IsNotNull(newDomainOrder.Id); Assert.AreNotEqual(0, newDomainOrder.Id); }