public async Task <LocationCreateModel> CreateLocation(LocationCreateModel data) { try { LocationCreateModel model = null; tblLocation dataLocation = await Task.Run(() => ManageLocation.InsertLocation(data.ConvertTotblLocation())); model = (await Task.Run(() => ManageLocation.GetLocationDetails(dataLocation.ID))).ConvertToLocation(); data.locationId = model.id; switch (data.companyType) { case "MSP": tblMSPLocationBranch dataMSP = await Task.Run(() => ManageMSP.InsertMSPLocationBranch(data.ConvertTotblMSPLocationBranch())); break; case "Customer": tblCustomerLocationBranch dataCustomer = await Task.Run(() => ManageCustomer.InsertCustomerLocationBranch(data.ConvertTotblCustomerLocationBranch())); break; case "Supplier": tblSupplierLocationBranch dataSupplier = await Task.Run(() => ManageSupplier.InsertSupplierLocationBranch(data.ConvertTotblSupplierLocationBranch())); break; } return(model); } catch (Exception) { throw; } }
public async Task DeleteLocation(LocationCreateModel data) { try { switch (data.companyType) { case "MSP": await Task.Run(() => ManageMSP.DeleteMSPLocationBranch(data.id, "Location")); break; case "Customer": await Task.Run(() => ManageCustomer.DeleteCustomerLocationBranch(data.id, "Location")); break; case "Supplier": await Task.Run(() => ManageSupplier.DeleteSupplierBranchLocation(data.id, "Location")); break; } await Task.Run(() => ManageLocation.DeleteLocation(data.id)); } catch (Exception) { throw; } }
public IActionResult ApiCreate(LocationCreateModel model) { if (!ModelState.IsValid) { return(Ok(ServiceResult.Error(ModelState))); } var location = new Location { Title = model.Title, Members = new List <LocationMember>() { new LocationMember() { FullName = model.ManagerFullName, Type = MemberType.Manager, PhoneNumbers = JsonConvert.SerializeObject(model.ManagerPhoneNumbers) } } }; var result = _repo.Create(location); return(Ok(result)); }
public async Task <IHttpActionResult> GetCustomerLocationBranch(LocationCreateModel data) { try { return(Ok(await LocationService.GetCustomerLocationBranches(data))); } catch (Exception) { throw; } }
public async Task <IHttpActionResult> GetAllLocations(LocationCreateModel data) { try { return(Ok((await LocationService.GetLocations(data)).AsQueryable())); } catch (Exception) { throw; } }
public async Task <IHttpActionResult> DeleteLocation(LocationCreateModel data) { try { await LocationService.DeleteLocation(data); return(Ok("Success")); } catch (Exception) { throw; } }
public async Task <LocationCreateModel> UpdateLocation(LocationCreateModel model) { try { tblLocation data = await Task.Run(() => ManageLocation.UpdateLocation(model.ConvertTotblLocation())); return(data.ConvertToLocation()); } catch (Exception) { throw; } }
public async Task <IHttpActionResult> creatLocation(LocationCreateModel data) { try { userId = User.Identity.GetUserId(); Helpers.Helpers.AddBaseProperties(data, "create", userId); return(Ok(await LocationService.CreateLocation(data))); } catch (Exception) { throw; } }
public static tblSupplierLocationBranch ConvertTotblSupplierLocationBranch(this LocationCreateModel data) { return(new tblSupplierLocationBranch() { ID = Convert.ToInt64(data.id), SupplierID = data.companyId, LocationID = data.locationId, BranchID = data.branchId, IsActive = data.isActive, IsDeleted = data.isDeleted ?? false, CreatedUserID = data.createdUserID, UpdatedUserID = data.updatedUserID, CreatedTimestamp = data.createdTimestamp ?? DateTime.Now, UpdatedTimestamp = data.updatedTimestamp ?? DateTime.Now }); }
public static tblLocation ConvertTotblLocation(this LocationCreateModel data) { return(new tblLocation() { ID = Convert.ToInt64(data.id), LocationName = data.locationName, StreetLine1 = data.streetLine1, StreetLine2 = data.streetLine2, City = data.city, StateID = Convert.ToInt16(data.stateId), CountryID = Convert.ToInt16(data.countryId), IsActive = data.isActive, IsDeleted = data.isDeleted ?? false, CreatedUserID = data.createdUserID, UpdatedUserID = data.updatedUserID, CreatedTimestamp = data.createdTimestamp ?? DateTime.Now, UpdatedTimestamp = data.updatedTimestamp ?? DateTime.Now }); }
public async Task <List <LocationCreateModel> > GetCustomerLocationBranches(LocationCreateModel data) { try { List <LocationCreateModel> res = null; List <tblCustomerLocationBranch> resData = null; long Id = data != null?Convert.ToInt64(data.companyId) : 0; switch (data.companyType) { case "Customer": resData = await Task.Run(() => ManageCustomer.GetCustomerLocationBranches(Id)); break; } res = resData.Select(a => a.ConvertToCustomerLocationBranch()).ToList(); return(res); } catch (Exception) { throw; } }
public async Task <List <LocationCreateModel> > GetLocations(LocationCreateModel data) { try { List <LocationCreateModel> res = null; List <tblLocation> resData = null; long Id = data != null?Convert.ToInt64(data.companyId) : 0; switch (data.companyType) { case "MSP": long id = Convert.ToInt64(ConfigurationManager.AppSettings["MSP_ID"]); Id = id != null ? id : Id; resData = await Task.Run(() => ManageMSP.GetMSPLocation(Id)); break; case "Customer": resData = await Task.Run(() => ManageCustomer.GetCustomerLocation(Id)); break; case "Supplier": resData = await Task.Run(() => ManageSupplier.GetSupplierLocation(Id)); break; } res = resData.Select(a => a.ConvertToLocation()).ToList(); return(res); } catch (Exception) { throw; } }
public async Task FullTest() { var mediator = ServiceProvider.GetService <IMediator>(); mediator.Should().NotBeNull(); var createModel = new LocationCreateModel { Name = "Location " + DateTime.Now.Ticks, Description = "Created from Unit Test", TenantId = Data.Constants.Tenant.Test }; var createCommand = new EntityCreateCommand <LocationCreateModel, LocationReadModel>(MockPrincipal.Default, createModel); var createResult = await mediator.Send(createCommand).ConfigureAwait(false); createResult.Should().NotBeNull(); var identifierQuery = new EntityIdentifierQuery <Guid, LocationReadModel>(MockPrincipal.Default, createResult.Id); var identifierResult = await mediator.Send(identifierQuery).ConfigureAwait(false); identifierResult.Should().NotBeNull(); identifierResult.Name.Should().Be(createModel.Name); var entityQuery = new EntityQuery { Sort = new List <EntitySort> { new EntitySort { Name = "Updated", Direction = "Descending" } }, Filter = new EntityFilter { Name = "Name", Value = "Location", Operator = "StartsWith" } }; var listQuery = new EntityPagedQuery <LocationReadModel>(MockPrincipal.Default, entityQuery); var listResult = await mediator.Send(listQuery).ConfigureAwait(false); listResult.Should().NotBeNull(); var patchModel = new JsonPatchDocument <Location>(); patchModel.Operations.Add(new Operation <Location> { op = "replace", path = "/Description", value = "Patch Update" }); var patchCommand = new EntityPatchCommand <Guid, LocationReadModel>(MockPrincipal.Default, createResult.Id, patchModel); var patchResult = await mediator.Send(patchCommand).ConfigureAwait(false); patchResult.Should().NotBeNull(); patchResult.Description.Should().Be("Patch Update"); var updateModel = new LocationUpdateModel { Name = patchResult.Name, Description = "Update Command", TenantId = patchResult.TenantId, RowVersion = patchResult.RowVersion }; var updateCommand = new EntityUpdateCommand <Guid, LocationUpdateModel, LocationReadModel>(MockPrincipal.Default, createResult.Id, updateModel); var updateResult = await mediator.Send(updateCommand).ConfigureAwait(false); updateResult.Should().NotBeNull(); updateResult.Description.Should().Be("Update Command"); var deleteCommand = new EntityDeleteCommand <Guid, LocationReadModel>(MockPrincipal.Default, createResult.Id); var deleteResult = await mediator.Send(deleteCommand).ConfigureAwait(false); deleteResult.Should().NotBeNull(); deleteResult.Id.Should().Be(createResult.Id); }