Exemplo n.º 1
0
        public IHttpActionResult Login(CUSTOM_LOGIN login)
        {
            ApiResData res = new ApiResData();

            try
            {
                if (!ModelState.IsValid)
                {
                    rs.SetErrorStatus(eFunc.fg.SFailed);
                    resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.DataNf, new Exception(eFunc.fg.DataIsntValid)));
                    return(Content(HttpStatusCode.NotFound, resObj));
                }

                TOURIS_TM_USER user     = repo.Login(login.Email, login.Password);
                TOURIS_TV_USER userView = new TOURIS_TV_USER();

                if (user != null)
                {
                    userView.ID                 = user.ID;
                    userView.USER_ID            = user.USER_ID;
                    userView.USER_MAIL          = user.USER_MAIL;
                    userView.USER_NAME          = user.USER_NAME;
                    userView.IS_SUPER_ADMIN     = user.IS_SUPER_ADMIN;
                    userView.LAST_LOGIN         = user.LAST_LOGIN;
                    userView.PASSWORD           = user.PASSWORD;
                    userView.PHOTO_PATH         = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().PHOTO_PATH;
                    userView.GENDER             = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().GENDER;
                    userView.BORN               = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().BORN;
                    userView.ADDRESS            = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().ADDRESS;
                    userView.DESCRIPTION        = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().DESCRIPTION;
                    userView.JOB                = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().JOB;
                    userView.COMPANY            = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().COMPANY;
                    userView.HOBBY              = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().HOBBY;
                    userView.CREATED_BY         = user.CREATED_BY;
                    userView.CREATED_TIME       = user.CREATED_TIME;
                    userView.LAST_MODIFIED_BY   = user.LAST_MODIFIED_BY;
                    userView.LAST_MODIFIED_TIME = user.LAST_MODIFIED_TIME;

                    if (user.TOURIS_TM_USER_PROFILE != null)
                    {
                        TOURIS_TV_USER_PROFILE userProfileView = new TOURIS_TV_USER_PROFILE();
                        userProfileView.ID                 = user.ID;
                        userProfileView.USER_ID_ID         = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().USER_ID_ID;
                        userProfileView.PHOTO_PATH         = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().PHOTO_PATH;
                        userProfileView.GENDER             = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().GENDER;
                        userProfileView.BORN               = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().BORN;
                        userProfileView.ADDRESS            = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().ADDRESS;
                        userProfileView.DESCRIPTION        = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().DESCRIPTION;
                        userProfileView.JOB                = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().JOB;
                        userProfileView.COMPANY            = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().COMPANY;
                        userProfileView.HOBBY              = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().HOBBY;
                        userProfileView.CREATED_BY         = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().CREATED_BY;
                        userProfileView.CREATED_TIME       = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().CREATED_TIME;
                        userProfileView.LAST_MODIFIED_BY   = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().LAST_MODIFIED_BY;
                        userProfileView.LAST_MODIFIED_TIME = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().LAST_MODIFIED_TIME;

                        if (user.TOURIS_TM_USER_PROFILE.FirstOrDefault().TOURIS_TM_USER_PROFILE_SOSMED.Count > 0)
                        {
                            foreach (var itemSosmed in user.TOURIS_TM_USER_PROFILE.FirstOrDefault().TOURIS_TM_USER_PROFILE_SOSMED)
                            {
                                TOURIS_TV_USER_PROFILE_SOSMED userProfileSosmedView = new TOURIS_TV_USER_PROFILE_SOSMED();
                                userProfileSosmedView.ID = user.ID;
                                userProfileSosmedView.USER_PROFILE_ID    = itemSosmed.USER_PROFILE_ID;
                                userProfileSosmedView.SOSMED_NAME        = itemSosmed.SOSMED_NAME;
                                userProfileSosmedView.SOSMED_PATH        = itemSosmed.SOSMED_PATH;
                                userProfileSosmedView.CREATED_BY         = itemSosmed.CREATED_BY;
                                userProfileSosmedView.CREATED_TIME       = itemSosmed.CREATED_TIME;
                                userProfileSosmedView.LAST_MODIFIED_BY   = itemSosmed.LAST_MODIFIED_BY;
                                userProfileSosmedView.LAST_MODIFIED_TIME = itemSosmed.LAST_MODIFIED_TIME;

                                userProfileView.TOURIS_TV_USER_PROFILE_SOSMED.Add(userProfileSosmedView);
                            }
                        }

                        userView.TOURIS_TV_USER_PROFILE.Add(userProfileView);
                    }

                    rs.SetSuccessStatus();
                }
                resObj = JObject.FromObject(res.ResGetDataTable(new object[] { userView }, null));

                return(Content(HttpStatusCode.OK, resObj));
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
                resObj = JObject.FromObject(res.ResGetDataTable(new object[] { rs }, new Exception(eFunc.fg.DataNf)));
                return(Content(HttpStatusCode.BadRequest, resObj));
            }
        }
Exemplo n.º 2
0
        public IHttpActionResult GridBind()
        {
            ApiResData res = new ApiResData();

            try
            {
                List <TOURIS_TM_USER> users     = repo.GridBind();
                List <TOURIS_TV_USER> userViews = new List <TOURIS_TV_USER>();

                if (users.Count > 0)
                {
                    foreach (var item in users)
                    {
                        TOURIS_TV_USER userView = new TOURIS_TV_USER();
                        userView.ID                 = item.ID;
                        userView.USER_ID            = item.USER_ID;
                        userView.USER_MAIL          = item.USER_MAIL;
                        userView.USER_NAME          = item.USER_NAME;
                        userView.IS_SUPER_ADMIN     = item.IS_SUPER_ADMIN;
                        userView.LAST_LOGIN         = item.LAST_LOGIN;
                        userView.PASSWORD           = item.PASSWORD;
                        userView.CREATED_BY         = item.CREATED_BY;
                        userView.CREATED_TIME       = item.CREATED_TIME;
                        userView.LAST_MODIFIED_BY   = item.LAST_MODIFIED_BY;
                        userView.LAST_MODIFIED_TIME = item.LAST_MODIFIED_TIME;

                        if (item.TOURIS_TM_USER_PROFILE.Count > 0)
                        {
                            TOURIS_TV_USER_PROFILE userProfileView = new TOURIS_TV_USER_PROFILE();
                            userProfileView.ID                 = item.ID;
                            userProfileView.USER_ID_ID         = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().USER_ID_ID;
                            userProfileView.PHOTO_PATH         = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().PHOTO_PATH;
                            userProfileView.GENDER             = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().GENDER;
                            userProfileView.BORN               = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().BORN;
                            userProfileView.ADDRESS            = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().ADDRESS;
                            userProfileView.DESCRIPTION        = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().DESCRIPTION;
                            userProfileView.JOB                = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().JOB;
                            userProfileView.COMPANY            = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().COMPANY;
                            userProfileView.HOBBY              = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().HOBBY;
                            userProfileView.CREATED_BY         = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().CREATED_BY;
                            userProfileView.CREATED_TIME       = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().CREATED_TIME;
                            userProfileView.LAST_MODIFIED_BY   = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().LAST_MODIFIED_BY;
                            userProfileView.LAST_MODIFIED_TIME = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().LAST_MODIFIED_TIME;

                            if (item.TOURIS_TM_USER_PROFILE.FirstOrDefault().TOURIS_TM_USER_PROFILE_SOSMED.Count > 0)
                            {
                                foreach (var itemSosmed in item.TOURIS_TM_USER_PROFILE.FirstOrDefault().TOURIS_TM_USER_PROFILE_SOSMED)
                                {
                                    TOURIS_TV_USER_PROFILE_SOSMED userProfileSosmedView = new TOURIS_TV_USER_PROFILE_SOSMED();
                                    userProfileSosmedView.ID = item.ID;
                                    userProfileSosmedView.USER_PROFILE_ID    = itemSosmed.USER_PROFILE_ID;
                                    userProfileSosmedView.SOSMED_NAME        = itemSosmed.SOSMED_NAME;
                                    userProfileSosmedView.SOSMED_PATH        = itemSosmed.SOSMED_PATH;
                                    userProfileSosmedView.CREATED_BY         = itemSosmed.CREATED_BY;
                                    userProfileSosmedView.CREATED_TIME       = itemSosmed.CREATED_TIME;
                                    userProfileSosmedView.LAST_MODIFIED_BY   = itemSosmed.LAST_MODIFIED_BY;
                                    userProfileSosmedView.LAST_MODIFIED_TIME = itemSosmed.LAST_MODIFIED_TIME;

                                    userProfileView.TOURIS_TV_USER_PROFILE_SOSMED.Add(userProfileSosmedView);
                                }
                            }

                            userView.TOURIS_TV_USER_PROFILE.Add(userProfileView);
                        }

                        userViews.Add(userView);
                    }
                    rs.SetSuccessStatus();
                }
                resObj = JObject.FromObject(res.ResGetDataTable(new object[] { userViews }, null));
                return(Content(HttpStatusCode.OK, resObj));
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
                resObj = JObject.FromObject(res.ResGetDataTable(new object[] { rs }, new Exception(eFunc.fg.DataNf)));
                return(Content(HttpStatusCode.BadRequest, resObj));
            }
        }