Пример #1
0
        public async Task <ActionResult <FacilityMaster> > PostFacility(FacilityMaster facility)
        {
            _context.FacilityMasters.Add(facility);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetFacility", new { id = facility.FacilityID }, facility));
        }
Пример #2
0
        public async Task Create_Faciltiy_Master_Test()
        {
            var facilityName = "Martin Memorial Medical Center - North Campus";
            var orderMap     = "0149600001496A000";

            IDbConnection smartAgentDb = new SqlConnection(ConfigurationManager.ConnectionStrings[_devAppConfigName].ConnectionString);
            var           kernel       = new StandardKernel(new RepoTestsModule(smartAgentDb));

            var clientLocationRepo = kernel.Get <IAsyncRepository <ClientLocations> >();

            var result = await clientLocationRepo.FindByName(facilityName);

            if (result.Any())
            {
                var facilites = new List <FacilityMaster>();
                var location  = result.SingleOrDefault();

                var facility = FacilityMaster.CreateFaciltiy(
                    facilityName,
                    Guid.NewGuid(),
                    orderMap,
                    location.ClientKey,
                    location.ClientLocationKey
                    );

                facilites.Add(facility);
                var facilityRepo = kernel.Get <IAsyncRepository <FacilityMaster> >();

                var facilityKey = await facilityRepo.AddAsync(facilites);

                writeToConsole("Created new facility! Key: ", facilityKey.ToString());
            }
        }
Пример #3
0
        public async Task <IActionResult> PutFacility(int id, FacilityMaster facility)
        {
            if (id != facility.FacilityID)
            {
                return(BadRequest());
            }

            _context.Entry(facility).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FacilityExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #4
0
        public async Task <IActionResult> GetFacilityMaster(int?skip, int?top, string columns, string FCTY_CODE, string FCTY_NAME, DateTime?FCTY_V_START_DATE)
        {
            int s = (skip == null) ? 0 : skip.GetValueOrDefault();
            int t = (top == null) ? 1000 : top.GetValueOrDefault();

            if (s < 0)
            {
                return(BadRequest("Skip can't be a negative number"));
            }
            if (t < 1)
            {
                return(BadRequest("Top can't be less then 1"));
            }

            if (columns != null)
            {
                columns = columns.Replace(" ", "");
            }

            /* This section is used to check the existence of columns suplied in the request,
             * and in the event of no columns being supplied finds a list of each column of the given model.
             */
            FacilityMaster obj  = new FacilityMaster();
            var            cols = obj.GetType().GetProperties().Select(e => e.Name.ToUpper()).ToArray();

            if (columns == null)
            {
                columns = string.Join(",", cols);
            }
            else
            {
                string[] colSplit = columns.Split(',');
                foreach (string col in colSplit)
                {
                    if (!cols.Contains(col.Trim().ToUpper()))
                    {
                        return(BadRequest(col + " is not a valid column"));
                    }
                }
            }

            /* This section takes care of the db request.
             * Here Linq.Dynamic.Core is used to dynamically select specific columns.
             */
            var result = _db.FacilityMaster
                         .Where(e =>
                                (e.FCTY_CODE == FCTY_CODE || FCTY_CODE == null) &&
                                (e.FCTY_NAME == FCTY_NAME || FCTY_NAME == null) &&
                                (e.FCTY_V_START_DATE >= FCTY_V_START_DATE || FCTY_V_START_DATE == null)
                                )
                         .Skip(s)
                         .Take(t)
                         .Select("new(" + columns + ")");

            return(Ok(await result.ToDynamicListAsync()));
        }
Пример #5
0
        public int DeleteSingleOrDefaultFacilityRecord(int selectedfacility)
        {
            List <UserLoginInformation> userinfo =
                _context.UserLoginInformations.Where(x => x.FacilityId == selectedfacility).ToList();
            List <UserFacility> userfacinfo =
                _context.UserFacilities.Where(x => x.FacilityId == selectedfacility).ToList();

            if (userinfo.Count == 0 && userfacinfo.Count == 0)
            {
                FacilityMaster facility =
                    _context.FacilityMasters.SingleOrDefault(x => x.FacilityMasterId.Equals(selectedfacility));
                _context.FacilityMasters.Remove(facility);
                _context.SaveChanges();
                return(1);
            }
            return(2);
        }
Пример #6
0
        public ActionResult GenerateReport(int selectedOrganisation, int selectedtype, int selectedstatus)
        {
            List <FacilityMaster> facilitymasters;

            if (selectedOrganisation == 0)
            {
                if (selectedstatus == 0)
                {
                    facilitymasters = FacilityMaster.GetAllFacilities();
                }
                else if (selectedstatus == 1)
                {
                    facilitymasters = FacilityMaster.GetAllActiveFacilities();
                }
                else
                {
                    facilitymasters = FacilityMaster.GetAllInActiveFacilities();
                }
            }
            else
            {
                Organisation org = _context.Organisations.Find(selectedOrganisation);

                if (selectedstatus == 0)
                {
                    facilitymasters = org.GetAssocaitedFacilities();
                }
                else if (selectedstatus == 1)
                {
                    facilitymasters = org.GetAssocaitedActiveFacilities();
                }
                else
                {
                    facilitymasters = org.GetAssocaitedInActiveFacilities();
                }
            }
            foreach (FacilityMaster facmaster in facilitymasters)
            {
                facmaster.AssociatedUsers = facmaster.GetAssocaitedFacilityAdmins();
            }


            return(performActionForReportType(selectedtype, facilitymasters));
        }
Пример #7
0
        public void UpdateFacilityMasterAndCreateFacilityTrans(FacilityMaster facilityMaster, FacilityTrans facilityTrans, string status, string userCode)
        {

            #region 记事务
            facilityTrans.FacilityCategory = facilityMaster.Category;
            facilityTrans.AssetNo = facilityMaster.AssetNo;
            facilityTrans.FacilityName = facilityMaster.Name;
            facilityTransMgrE.CreateFacilityTrans(facilityTrans);
            #endregion

            #region 更新状态
            facilityMaster.Status = status;
            facilityMaster.LastModifyDate = DateTime.Now;
            facilityMaster.LastModifyUser = userCode;
            UpdateFacilityMaster(facilityMaster);
            #endregion

            #region 保养和检测的需要自动关闭对应的ISI任务
            if (facilityTrans.TransType == FacilityConstants.CODE_MASTER_FACILITY_TRANSTYPE_MAINTAIN_FINISH
                || facilityTrans.TransType == FacilityConstants.CODE_MASTER_FACILITY_TRANSTYPE_INSPECT_FINISH)
            {
                DetachedCriteria criteria = DetachedCriteria.For(typeof(TaskMstr));
                criteria.CreateAlias("TaskSubType", "t");
                criteria.Add(Expression.In("Status", new string[] { ISIConstants.CODE_MASTER_ISI_STATUS_VALUE_ASSIGN, ISIConstants.CODE_MASTER_ISI_STATUS_VALUE_INPROCESS }));
                criteria.Add(Expression.Eq("t.Code", "SSGL"));
                criteria.Add(Expression.Eq("Desc2", facilityMaster.FCID));
                //  criteria.Add(Expression.Eq("f.Status", FacilityConstants.CODE_MASTER_FACILITY_STATUS_AVAILABLE));
                IList<TaskMstr> facilityTaskList = criteriaMgrE.FindAll<TaskMstr>(criteria);
                if (facilityTaskList != null && facilityTaskList.Count > 0)
                {
                    User user = userMgrE.LoadUser(userCode);
                    TaskMstr t = facilityTaskList.First(); //只关第一条
                    if (t.Status == ISIConstants.CODE_MASTER_ISI_STATUS_VALUE_ASSIGN)
                    {
                        taskMgrE.ConfirmTask(t.Code, user);
                    }
                    taskMgrE.CompleteTask(t.Code, user);
                    taskMgrE.CloseTask(t.Code, user);
                }
            }
            #endregion
        }
Пример #8
0
        public ActionResult CheckIfValidFacilityName(string facility)
        {
            string[]       strings    = facility.Split(new string[] { "||||" }, StringSplitOptions.None);
            FacilityMaster res        = null;
            string         name       = strings[0];
            int            facilityid = int.Parse(strings[1]);

            if (facilityid == 0)
            {
                res = _context.FacilityMasters.SingleOrDefault(x => x.FacilityMasterName == name);
            }
            else
            {
                res = _context.FacilityMasters.SingleOrDefault(x => x.FacilityMasterName == name && x.FacilityMasterId != facilityid);
            }
            if (res != null)
            {
                return(Json("FacilityName Already Exists.Use Another Facility Name", JsonRequestBehavior.AllowGet));
            }
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Пример #9
0
        public ActionResult Result(int currentrecord)
        {
            FacilityMaster @facility           = _context.FacilityMasters.Find(currentrecord);
            Organisation   currentOrganisation = @facility.OOrganisation;
            List <int>     participantsIds     = null;

            if (currentrecord != 0)
            {
                List <UserLoginInformation> usersInDb = new List <UserLoginInformation>();

                usersInDb.AddRange(@facility.GetAssocaitedFacilityAdmins());

                participantsIds = usersInDb.Select(x => x.USERID).ToList();
            }
            List <MyNode> nodes = new List <MyNode>();

            MyOrganisation @org = new MyOrganisation();

            @org.Name  = currentOrganisation.Name;
            @org.Value = currentOrganisation.OrganisationId;

            MyNode orgNode = new MyNode
            {
                text      = org.Name,
                value     = org.Value,
                icon      = "glyphicon glyphicon-home",
                backColor = "#ffffff",
                color     = "#428bca",
                //state = new state() { @checked = true, disabled = false, expanded = true, selected = false },
                nodetype = MyNodeType.Organisation
            };

            List <MyFacility> facilities = new List <MyFacility>
            {
                new MyFacility
                {
                    Name = @facility.FacilityMasterName,
                    ParentOrganisationId = @facility.OrganisationId,
                    Value = @facility.FacilityMasterId
                }
            };

            if (facilities.Count > 0)
            {
                orgNode.nodes = new List <MyNode>();
                foreach (MyFacility @fac in facilities)
                {
                    MyNode facNode = new MyNode
                    {
                        parent    = orgNode.value,
                        text      = fac.Name,
                        value     = fac.Value,
                        icon      = "glyphicon glyphicon-th-list",
                        backColor = "#ffffff",
                        color     = "#66512c",
                        //state = new state() { @checked = true, disabled = false, expanded = true, selected = false },
                        nodetype = MyNodeType.Facility
                    };
                    List <MyUser> users = @fac.GetAllMatchingUsers();
                    if (users != null && users.Count > 0)
                    {
                        facNode.nodes = new List <MyNode>();
                        foreach (MyUser @user in users)
                        {
                            MyNode userNode = new MyNode
                            {
                                parent    = facNode.value,
                                text      = user.Name,
                                value     = user.Value,
                                icon      = "glyphicon glyphicon-user",
                                backColor = "#ffffff",
                                color     = "#31708f",
                                nodetype  = MyNodeType.User
                            };
                            if (ChatGroupController.CheckIfMatchingMyUserExists(participantsIds, userNode) != null)
                            {
                                userNode.state = new state
                                {
                                    @checked = true,
                                    disabled = false,
                                    expanded = true,
                                    selected = false
                                };
                            }
                            facNode.nodes.Add(userNode);
                        }
                    }
                    orgNode.nodes.Add(facNode);
                }
            }
            nodes.Add(orgNode);
            return(Json(nodes, JsonRequestBehavior.AllowGet));
        }
Пример #10
0
        public JsonResult getMatchingFacility(int selectedfacility)
        {
            FacilityMaster facilityinfo = _context.FacilityMasters.SingleOrDefault(x => x.FacilityMasterId.Equals(selectedfacility));

            return(Json(facilityinfo, JsonRequestBehavior.AllowGet));
        }
Пример #11
0
        public FacilityMaster Updateobject(int id, FacilityMaster filled)
        {
            FacilityMaster obj = _context.FacilityMasters.Find(id);

            PropertyInfo[] props = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
            foreach (PropertyInfo prop in props)
            {
                object currentprop = prop.GetValue(filled);
                if (currentprop is Int32)
                {
                    int currentint = (int)currentprop;
                    if (currentint == 0)
                    {
                        prop.SetValue(filled, prop.GetValue(obj), null);
                    }
                }
                else if (currentprop is Int16)
                {
                    Int16 currentInt16 = (Int16)currentprop;
                    if (currentInt16 == 0)
                    {
                        prop.SetValue(filled, prop.GetValue(obj), null);
                    }
                }
                else if (currentprop is Byte)
                {
                    Byte currentByte = (Byte)currentprop;
                    if (currentByte == 0)
                    {
                        prop.SetValue(filled, prop.GetValue(obj), null);
                    }
                }
                else if (currentprop is Boolean)
                {
                    Boolean currentBoolean = (Boolean)currentprop;
                    if (currentBoolean == (Boolean)prop.GetValue(obj))
                    {
                        prop.SetValue(filled, prop.GetValue(obj), null);
                    }
                }
                else if (currentprop is String)
                {
                    prop.SetValue(filled, (String)currentprop, null);
                }
                else if (currentprop is DateTime)
                {
                    DateTime currentDateTime = (DateTime)currentprop;
                    if (currentDateTime == new DateTime())
                    {
                        prop.SetValue(filled, prop.GetValue(obj), null);
                    }
                }
                else
                {
                    if (currentprop == null)
                    {
                        prop.SetValue(filled, prop.GetValue(obj), null);
                    }
                }
            }
            return(filled);
        }
Пример #12
0
        public string UpdateFacilittMaster(FacilityMaster facilityinfo)
        {
            try
            {
                UserLoginInformation loggedinUser = (UserLoginInformation)LoginController.ActiveUser;
                if (facilityinfo.FacilityMasterId == 0)
                {
                    facilityinfo.CreatedById  = loggedinUser.USERID.ToString();
                    facilityinfo.ModifiedById = loggedinUser.USERID.ToString();
                    facilityinfo.CreatedDate  = DateTime.Now;
                    facilityinfo.ModifiedDate = DateTime.Now;
                    _context.FacilityMasters.Add(facilityinfo);
                    _context.SaveChanges();
                }
                else
                {
                    try
                    {
                        using (TransactionScope transactionScope = new TransactionScope())
                        {
                            try
                            {
                                using (kryptoEntities1 db = new kryptoEntities1())
                                {
                                    facilityinfo = Updateobject(facilityinfo.FacilityMasterId, facilityinfo);
                                    facilityinfo.ModifiedById    = loggedinUser.USERID.ToString();
                                    facilityinfo.ModifiedDate    = DateTime.Now;
                                    db.Entry(facilityinfo).State = EntityState.Modified;
                                    db.SaveChanges();

                                    List <MyNode> responseNodes =
                                        JsonConvert.DeserializeObject <List <MyNode> >(facilityinfo.UserSelections);
                                    List <UserLoginInformation> usersInDb = new List <UserLoginInformation>();

                                    usersInDb.AddRange(facilityinfo.GetAssocaitedFacilityAdmins());

                                    List <int> indb         = usersInDb.Select(x => x.USERID).ToList();
                                    List <int> inselections = responseNodes.Select(x => x.value).ToList();

                                    var toInclude = UserDatatablesController.ExcludedRight(indb, inselections);
                                    var toExclude = UserDatatablesController.ExcludedLeft(indb, inselections);

                                    foreach (int @in in toInclude)
                                    {
                                        UserLoginInformation current = db.UserLoginInformations.Find(@in);
                                        current.IsFacilityAdmin = true;
                                        db.Entry(current).State = EntityState.Modified;
                                    }
                                    foreach (int @out in toExclude)
                                    {
                                        UserLoginInformation current = db.UserLoginInformations.Find(@out);
                                        current.IsFacilityAdmin = false;
                                        db.Entry(current).State = EntityState.Modified;
                                    }
                                    db.SaveChanges();
                                }
                                transactionScope.Complete();
                            }
                            catch (Exception ee)
                            {
                                return("FAIL");
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        return("FAIL");
                    }
                }
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                return("FAIL");
            }
            return("SUCESS");
        }
Пример #13
0
        public override void CreateFacilityMaster(FacilityMaster facilityMaster)
        {
            base.CreateFacilityMaster(facilityMaster);

            #region 记事务

            FacilityTrans facilityTrans = new FacilityTrans();
            facilityTrans.CreateDate = DateTime.Now;
            facilityTrans.CreateUser = facilityMaster.CreateUser;
            facilityTrans.EffDate = DateTime.Now.Date;
            facilityTrans.FCID = facilityMaster.FCID;
            facilityTrans.FromChargePerson = facilityMaster.CurrChargePerson;
            facilityTrans.FromChargePersonName = facilityMaster.CurrChargePersonName;
            facilityTrans.FromOrganization = facilityMaster.ChargeOrganization;
            facilityTrans.FromChargeSite = facilityMaster.ChargeSite;
            facilityTrans.ToChargePerson = facilityMaster.CurrChargePerson;
            facilityTrans.ToChargePersonName = facilityMaster.CurrChargePersonName;
            facilityTrans.ToOrganization = facilityMaster.ChargeOrganization;
            facilityTrans.ToChargeSite = facilityMaster.ChargeSite;
            facilityTrans.TransType = FacilityConstants.CODE_MASTER_FACILITY_TRANSTYPE_CREATE;

            facilityTrans.AssetNo = facilityMaster.AssetNo;
            facilityTrans.FacilityName = facilityMaster.Name;
            facilityTrans.FacilityCategory = facilityMaster.Category;
            facilityTransMgrE.CreateFacilityTrans(facilityTrans);
            #endregion


        }
Пример #14
0
        public void UpdateFacilityMasterMaintain(FacilityMaster facilityMaster)
        {

            #region 计算保养间隔期,按天的
            if (facilityMaster.MaintainType != null && facilityMaster.MaintainType != FacilityConstants.CODE_MASTER_FACILITY_MAINTAIN_TYPE_ONCE)
            {
                facilityMaster.MaintainTypePeriod = Convert.ToInt32(facilityMaster.MaintainType.Substring(0, facilityMaster.MaintainType.Length - 1));
            }
            #endregion
            #region 计算下次时间
            DateTime dateTimeNow = DateTime.Now.Date;
            if (facilityMaster.MaintainStartDate == null)
            {
                facilityMaster.MaintainStartDate = dateTimeNow;
            }

            //下次提醒时间
            facilityMaster.NextMaintainTime = facilityMaster.MaintainStartDate.Value.AddDays(facilityMaster.MaintainLeadTime.HasValue ? 0 - facilityMaster.MaintainLeadTime.Value : 0);

            this.Update(facilityMaster);
            #endregion
        }
Пример #15
0
        public async Task Create_Client_Test()
        {
            // Get connection prepare for data entry
            IDbConnection smartAgentDb = new SqlConnection(ConfigurationManager.ConnectionStrings[_devAppConfigName].ConnectionString);

            // Instantiate Repositories needed for data entry
            var kernel = new StandardKernel(new RepoTestsModule(smartAgentDb));

            // Start client creation process.
            var clientName   = "Community Health Systems (CHS)";
            var clientKey    = new Guid("5ee74d8b-f1f9-4464-a1e3-aa7c4335d12d");
            var howToDeliver = "OCSVC";

            if (clientKey == new Guid("00000000-0000-0000-0000-000000000000"))
            {
                clientKey = Guid.NewGuid();
            }

            var client = new ClientMaster(clientName: clientName, clientKey: clientKey, howToDeliver: howToDeliver);

            var    clientLocationName = "CHS - Deaconess Med Ctr";
            var    clientId           = "109781";
            string facilityId         = "VAC";
            var    tpId       = "178995";
            var    lastUserId = "kris.lindsey";

            IEnumerable <ClientMaster> clients = new List <ClientMaster>();

            var clientMasterRepo   = kernel.Get <IAsyncRepository <ClientMaster> >();
            var clientLocationRepo = kernel.Get <IAsyncRepository <ClientLocations> >();

            //Check to see if client already exists in data
            clients = await clientMasterRepo.FindByName(client.ClientName);

            // If one exits add location data
            if (clients.Any())
            {
                var locations         = new List <ClientLocations>();
                var clientLocationKey = Guid.NewGuid();

                var clientLocation = ClientLocations.CreateClientLocation
                                     (
                    clientLocationName,
                    clientKey,
                    clientLocationKey,
                    clientId,
                    tpId,
                    facilityId
                                     );

                clientLocation.LastUserId = lastUserId;

                locations.Add(clientLocation);
                var clientLocationEntryResult = await clientLocationRepo.AddAsync(locations);

                if (clientLocationEntryResult == clientLocation.ClientLocationKey)
                {
                    var facilityRepo = kernel.Get <IAsyncRepository <FacilityMaster> >();

                    var newFacility = FacilityMaster.CreateFaciltiy
                                      (
                        clientLocation.ClientLocationName,
                        Guid.NewGuid(),
                        "0144300301443003",
                        clientLocation.ClientKey,
                        clientLocation.ClientLocationKey
                                      );

                    var facilites = new List <FacilityMaster>();

                    facilites.Add(newFacility);
                    var result = await facilityRepo.AddAsync(facilites);

                    var mappingValues = new List <PayerWebsiteMappingValue>();

                    var newMappingValue = PayerWebsiteMappingValue.CreateWebisteMappingValue
                                          (
                        clientKey,
                        clientLocationKey
                                          );

                    mappingValues.Add(newMappingValue);

                    var pwmvRepo = kernel.Get <IAsyncRepository <PayerWebsiteMappingValue> >();
                    var mvresult = await pwmvRepo.AddAsync(mappingValues);

                    if (!string.IsNullOrWhiteSpace(clientLocationName))
                    {
                        var criteriaRepo       = new CreateSmartAgentUserRepo(smartAgentDb);
                        var criteriaSearchRepo = kernel.Get <IAsyncRepository <CriteriaDetails> >();
                        //var criteriaSetName = "";

                        var insuranceName   = "Emblem Submit";
                        var clientkey       = new Guid("6648E492-D332-443B-8273-77992C36CD3E");
                        var criteriaSetname = clientName + insuranceName;
                        var scriptKey       = new Guid("CD2D1C15-D197-E211-B890-000C29729DFF");
                        var criteriaSetKey  = Guid.NewGuid();
                        var iprkey          = "PCEMBLEM01";

                        var c = Criteria.CreateCriteria
                                (
                            criteriaSetname,
                            criteriaSetKey,
                            scriptKey,
                            iprkey,
                            clientkey,
                            clientLocationKey,
                            "kris.lindsey",
                            ""
                                );

                        var critera = await criteriaSearchRepo.FindByName(clientLocationName);

                        if (critera.Any())
                        {
                            Console.WriteLine("Found records! nothing to do hear :)");
                            return;
                        }

                        else
                        {
                            var results = await criteriaRepo.CreateCriteraRecords(c);

                            Console.WriteLine("criteria created: ", result);
                        }
                    }
                }
            }
            //If not create client master record and then procedd to enter client data.
            else
            {
                var cs = new List <ClientMaster>();
                cs.Add(client);
                var result = await clientMasterRepo.AddAsync(cs);

                if (result == clientKey)
                {
                }
            }

            foreach (var item in clients)
            {
                writeToConsole(item.ClientName + " ", item.ClientKey);
            }
        }
        public ActionResult GenerateReport(int selectedOrg, int selectedFacility, int selectedstatus, int selectedtype)
        {
            bool includeFacInCondition = false;

            var includeOrgInCondition = PerformActionForSelectedOrganisation(selectedOrg);

            if (includeOrgInCondition)
            {
                includeFacInCondition = performActionForSelectedFacility(selectedFacility);
            }
            var includestatusAsCondition = performActionForSelectedstatus(selectedstatus);

            List <UserLoginInformation> users = new List <UserLoginInformation>();

            if (!includeOrgInCondition)
            {
                if (!includestatusAsCondition)
                {
                    users = _context.UserLoginInformations.Where(x => x.Status == 1).ToList();
                }
                else
                {
                    if (selectedstatus == 1)
                    {
                        foreach (Organisation @orgObj in _context.Organisations.Where(x => x.Status == 1).ToList())
                        {
                            foreach (FacilityMaster @facility in orgObj.GetAssocaitedFacilities())
                            {
                                users.AddRange(@facility.GetAssocaitedActiveUsers());
                            }
                        }
                    }
                    else if (selectedstatus == 2)
                    {
                        foreach (Organisation @orgObj in _context.Organisations.Where(x => x.Status == 1).ToList())
                        {
                            foreach (FacilityMaster @facility in orgObj.GetAssocaitedFacilities())
                            {
                                users.AddRange(@facility.GetAssocaitedInActiveUsers());
                            }
                        }
                    }
                    else
                    {
                        foreach (Organisation @orgObj in _context.Organisations.Where(x => x.Status == 1).ToList())
                        {
                            foreach (FacilityMaster @facility in orgObj.GetAssocaitedFacilities())
                            {
                                users.AddRange(@facility.GetAssocaitedUsers());
                            }
                        }
                    }
                }
            }
            else
            {
                if (includeFacInCondition)
                {
                    FacilityMaster facility = _context.FacilityMasters.Find(selectedFacility);
                    if (selectedstatus == 1)
                    {
                        users.AddRange(@facility.GetAssocaitedActiveUsers());
                    }
                    else if (selectedstatus == 2)
                    {
                        users.AddRange(@facility.GetAssocaitedInActiveUsers());
                    }
                    else
                    {
                        users.AddRange(@facility.GetAssocaitedUsers());
                    }
                }
                else
                {
                    Organisation orgObj = _context.Organisations.Find(selectedOrg);
                    if (selectedstatus == 1)
                    {
                        foreach (FacilityMaster @facility in orgObj.GetAssocaitedFacilities())
                        {
                            users.AddRange(@facility.GetAssocaitedActiveUsers());
                        }
                    }
                    else if (selectedstatus == 2)
                    {
                        foreach (FacilityMaster @facility in orgObj.GetAssocaitedFacilities())
                        {
                            users.AddRange(@facility.GetAssocaitedInActiveUsers());
                        }
                    }
                    else
                    {
                        foreach (FacilityMaster @facility in orgObj.GetAssocaitedFacilities())
                        {
                            users.AddRange(@facility.GetAssocaitedUsers());
                        }
                    }
                }
            }
            return(PerformActionForReportType(selectedtype, users));
        }