示例#1
0
 public SimpleUser(user user)
 {
     id       = user.id;
     username = user.full_name;
 }
示例#2
0
        public ActionResult listado(string Error, string searchStr = "", int idCategory = 0)
        {
            if (Session["USER_ID"] != null)
            {
                long userId  = (long)Session["USER_ID"];
                user curUser = entities.users.Find(userId);
                List <ShowMessage> pubMessageList = ep.GetChatMessages(userId);
                List <document>    document_list  = new List <document>();

                long communityAct = Convert.ToInt64(Session["CURRENT_COMU"]);

                Dictionary <long, string> categoryDict = new Dictionary <long, string>();
                if (searchStr == "" && idCategory == 0)
                {
                    var query = (from r in entities.documents where r.community_id == communityAct select r);
                    document_list = query.ToList();
                }
                else if (searchStr != "" && idCategory == 0)
                {
                    var query1 = (from r in entities.documents
                                  where r.first_name.Contains(searchStr) == true && r.community_id == communityAct
                                  select r);
                    document_list = query1.ToList();
                }
                else if (searchStr == "" && idCategory != 0)
                {
                    var query2 = (from r in entities.documents
                                  where r.document_type.id == idCategory && r.community_id == communityAct
                                  select r
                                  );
                    document_list = query2.ToList();
                }
                else
                {
                    var query3 = (from r in entities.documents
                                  where r.first_name.Contains(searchStr) == true &&
                                  r.document_type.id == idCategory && r.community_id == communityAct
                                  select r);
                    document_list = query3.ToList();
                }

                List <document_type> document_category_list = entities.document_type.Where(x => x.community_id == communityAct).ToList();
                documentosViewModel  viewModel = new documentosViewModel();

                titulosList             = ep.GetTitulosByTitular(userId);
                listComunities          = ep.GetCommunityListByTitular(titulosList);
                viewModel.communityList = listComunities;

                document_type document_type = entities.document_type.Find(idCategory);
                viewModel.side_menu = "documentos";
                if (idCategory != 0)
                {
                    viewModel.side_sub_menu = "documentos_" + document_type.type_name;
                }
                else
                {
                    viewModel.side_sub_menu = "documentos_listado";
                }
                viewModel.document_category_list = document_category_list;
                viewModel.documentList           = document_list;
                viewModel.searchStr      = searchStr;
                viewModel.typeID         = idCategory;
                viewModel.curUser        = curUser;
                viewModel.pubTaskList    = ep.GetNotifiTaskList(userId);
                viewModel.pubMessageList = pubMessageList;
                viewModel.messageCount   = ep.GetUnreadMessageCount(pubMessageList);
                ViewBag.msgError         = Error;
                return(View(viewModel));
            }
            else
            {
                return(Redirect(ep.GetLogoutUrl()));
            }
        }
        //-----------------افزودن کاربر جدید-----------------//
        public static bool addNewUser(Array[] userInfo, int _unitID, int _roleID)
        {
            manageCallsEntities2 db = new manageCallsEntities2();
            bool result             = false;//نتیجه ی عملیات

            bool   gender;
            var    userName     = userInfo[0].ToString();
            var    firstName    = userInfo[1].ToString();
            var    lastName     = userInfo[2].ToString();
            string nationalCode = userInfo[3].ToString();
            var    email        = userInfo[4].ToString();

            /* تعیین نقش و واحد :/ */

            //تعیین جنسیت
            try
            {
                if (Convert.ToInt16(userInfo[5]) == 0)//female
                {
                    gender = true;
                }
                else //male
                {
                    gender = false;
                }
            }
            catch
            {
                return(result);
            }

            //بررسی عدم تکراری بودن کاربر
            try
            {
                var existUser = db.users.FirstOrDefault(p => p.nationalCode.Equals(nationalCode));
                if (existUser == null)
                {
                    return(result);
                }

                //اضافه کردن کاربر
                else
                {
                    //اضافه کردن به جدول کاربران
                    user newUser = new user();
                    newUser.userName     = userName;
                    newUser.name         = firstName;
                    newUser.familyName   = lastName;
                    newUser.nationalCode = nationalCode;
                    newUser.email        = email;
                    newUser.gender       = gender;
                    newUser.accepted     = true;
                    db.users.Add(newUser);
                    db.SaveChanges();

                    //اضافه کردن به جدول roleinunit
                    roleInUnit newRoleInUnit = new roleInUnit();
                    newRoleInUnit.role_id = _roleID;
                    newRoleInUnit.unit_id = _unitID;
                    newRoleInUnit.user_id = newUser.id;
                    db.roleInUnits.Add(newRoleInUnit);
                    db.SaveChanges();

                    result = true;
                }
            }
            catch
            {
                return(result);
            }

            return(result);
        }
示例#4
0
        public ActionResult reservar(long?id)
        {
            if (Session["USER_ID"] != null)
            {
                if (Session["CURRENT_COMU"] != null)
                {
                    if (id != null)
                    {
                        efac facilidad = entities.efacs.Find(id);
                        if (facilidad != null)
                        {
                            try{
                                long communityAct = Convert.ToInt64(Session["CURRENT_COMU"]);
                                long userId       = (long)Session["USER_ID"];
                                user curUser      = entities.users.Find(userId);
                                List <ShowMessage>   pubMessageList = ep.GetChatMessages(userId);
                                facilidadesViewModel viewModel      = new facilidadesViewModel();
                                string        inicio     = Convert.ToString(facilidad.start_time);
                                string        final      = Convert.ToString(facilidad.end_time);
                                TimeSpan      horaInicio = TimeSpan.Parse(inicio);
                                TimeSpan      horaFin    = TimeSpan.Parse(final);
                                TimeSpan      masU       = TimeSpan.FromHours(1);
                                List <string> timeList   = new List <string>();
                                while (horaInicio < horaFin)
                                {
                                    timeList.Add(
                                        horaInicio.ToString("hh':'mm") + " - " +
                                        horaInicio.Add(masU).ToString("hh':'mm"));

                                    horaInicio = horaInicio.Add(masU);
                                }
                                titulosList                      = ep.GetTitulosByTitular(userId);
                                listComunities                   = ep.GetCommunityListByTitular(titulosList);
                                viewModel.communityList          = listComunities;
                                viewModel.timeList               = timeList;
                                viewModel.facilidadSe            = facilidad;
                                viewModel.side_menu              = "reservar";
                                viewModel.side_sub_menu          = "facilidades_reservar";
                                viewModel.curUser                = curUser;
                                viewModel.document_category_list = entities.document_type.Where(x => x.community_id == communityAct).ToList();
                                viewModel.pubTaskList            = ep.GetNotifiTaskList(userId);
                                viewModel.pubMessageList         = pubMessageList;
                                viewModel.messageCount           = ep.GetUnreadMessageCount(pubMessageList);
                                viewModel.communityName          = ep.GetCommunityCoInfo(userId)[0];
                                viewModel.communityApart         = ep.GetCommunityCoInfo(userId)[1];
                                return(View(viewModel));
                            }
                            catch (Exception ex)
                            {
                                return(Redirect(Url.Action("error", "control", new { Error = "Reservar facilidad: ", ex.Message })));
                            }
                        }
                        else
                        {
                            return(Redirect(Url.Action("disponibles", "facilidades", new { Error = "No existe la facilidad" })));
                        }
                    }
                    else
                    {
                        return(Redirect(Url.Action("disponibles", "facilidades")));
                    }
                }
                else
                {
                    return(Redirect(Url.Action("disponibles", "facilidades", new { Error = "No permitido. Usted no pertence a ninguna comunidad" })));
                }
            }
            else
            {
                return(Redirect(ep.GetLogoutUrl()));
            }
        }