Exemplo n.º 1
0
        public async Task <ServicePlanModel> UpdateServicePlan(string partition, string userId, ServicePlanModel servicePlanModel)
        {
            string           whereClause = " WHERE Tasks.id= '" + servicePlanModel.id + "'";
            ServicePlanModel servicePlan = new ServicePlanModel();
            var services = await _cosmosDBOperationsRepository.GetItemsByQueryFromCollectionAsync(whereClause, partition, collectionId);

            if (services != null)
            {
                servicePlan = services[0];
            }
            if (servicePlan != null)
            {
                servicePlan.ServicePlanName = servicePlanModel.ServicePlanName;
                servicePlan.ServiceTypeId   = servicePlanModel.ServiceTypeId;
                servicePlan.VehicleId       = servicePlanModel.VehicleId;
                servicePlan.WorkShopDetail  = servicePlanModel.WorkShopDetail;
                servicePlan.ServiceInterval = servicePlanModel.ServiceInterval;
                servicePlan.ScheduleService = servicePlanModel.ScheduleService;
                servicePlan.Notify          = servicePlanModel.Notify;
                servicePlan.ModifiedBy      = userId;
                servicePlan.ModifiedOn      = DateTime.Now;
                servicePlan = await _cosmosDBOperationsRepository.UpdateDocumentFromCollection(servicePlan.id, servicePlan, partition, collectionId);
            }
            return(servicePlan);
        }
Exemplo n.º 2
0
        public async Task <bool> DeleteData(string[] ids, string partition, string userId)
        {
            try
            {
                if (ids.Any())
                {
                    foreach (var id in ids)
                    {
                        ServicePlanModel servicePlan = await _cosmosDBOperationsRepository.GetItemFromCollectionAsync(id, partition, collectionId);

                        if (servicePlan != null)
                        {
                            servicePlan.IsDeleted  = true;
                            servicePlan.ModifiedBy = userId;
                            servicePlan.ModifiedOn = DateTime.Now;
                            var response = await _cosmosDBOperationsRepository.UpdateDocumentFromCollection(id, servicePlan, partition, collectionId);
                        }
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                Inseego.Utils.Shared.ExceptionHandler.LogException("DeleteData had an issue", e);
                throw;
            }
        }
Exemplo n.º 3
0
        public async Task <ServicePlanModel> UpdateServicePlanStatus(string partition, string userId, string id, int servicePlanStatus)
        {
            ServicePlanModel servicePlan = await _cosmosDBOperationsRepository.GetItemFromCollectionAsync(id, partition, collectionId);

            if (servicePlan != null)
            {
                servicePlan.ServicePlanStatus = servicePlanStatus;
                servicePlan.ModifiedBy        = userId;
                servicePlan.ModifiedOn        = DateTime.Now;
                servicePlan = await _cosmosDBOperationsRepository.UpdateDocumentFromCollection(servicePlan.id, servicePlan, partition, collectionId);
            }
            return(servicePlan);
        }
        public async Task <ServicePlanModel> UpdateServicePlan(string tenantId, string userId, ServicePlanRequest servicePlanRequest)
        {
            ServicePlanModel servicePlanModel = new ServicePlanModel();

            CommonFunctions.CopyProperties(servicePlanRequest, servicePlanModel);
            CommonFunctions.CopyProperties(servicePlanRequest.WorkShopDetail, servicePlanModel.WorkShopDetail);
            CommonFunctions.CopyProperties(servicePlanRequest.ServiceInterval, servicePlanModel.ServiceInterval);
            CommonFunctions.CopyProperties(servicePlanRequest.ScheduleService, servicePlanModel.ScheduleService);
            CommonFunctions.CopyProperties(servicePlanRequest.Notify, servicePlanModel.Notify);
            servicePlanModel = await _servicePlanRepository.UpdateServicePlan(tenantId, userId, servicePlanModel);

            return(servicePlanModel);
        }
        /// <summary>
        /// Save service Plan data
        /// </summary>
        /// <param name="servicePlanRequest"></param>
        /// <param name="tenantId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public async Task <ServicePlanModel> SaveServicePlan(ServicePlanRequest servicePlanRequest, string tenantId, string userId)
        {
            ServicePlanModel servicePlanModel = new ServicePlanModel();

            CommonFunctions.CopyProperties(servicePlanRequest, servicePlanModel);
            CommonFunctions.CopyProperties(servicePlanRequest.WorkShopDetail, servicePlanModel.WorkShopDetail);
            CommonFunctions.CopyProperties(servicePlanRequest.ServiceInterval, servicePlanModel.ServiceInterval);
            CommonFunctions.CopyProperties(servicePlanRequest.ScheduleService, servicePlanModel.ScheduleService);
            CommonFunctions.CopyProperties(servicePlanRequest.Notify, servicePlanModel.Notify);
            servicePlanModel.CreatedBy = userId;
            servicePlanModel.CreatedOn = DateTime.Now;
            servicePlanModel.IsActive  = true;
            servicePlanModel.IsDeleted = false;
            servicePlanModel.tenantId  = tenantId;
            // await _cosmosDBOperationsRepository.CreateCollectionIfNotExistsAsync(servicePlanCollectionId);
            servicePlanModel = await _cosmosDBOperationsRepository.AddDocumentIntoCollectionAsync(servicePlanModel, userId, tenantId, servicePlanCollectionId);

            return(servicePlanModel);
        }
        public async Task <ServicePlanModel> UpdateServicePlanStatus(string tenantId, string userId, string id, ServicePlanStatus servicePlanStatus)
        {
            ServicePlanModel servicePlanModel = await _servicePlanRepository.UpdateServicePlanStatus(tenantId, userId, id, (int)servicePlanStatus);

            return(servicePlanModel);
        }