Beispiel #1
0
        private ResultStatus DeleteUserProfileSosmed(TOURIS_TM_USER_PROFILE_SOSMED userProfileSosmed)
        {
            TOURIS_TM_USER_PROFILE_SOSMED userProfileSosmedDel = _ctx.TOURIS_TM_USER_PROFILE_SOSMED.Find(userProfileSosmed.ID);

            _ctx.TOURIS_TM_USER_PROFILE_SOSMED.Remove(userProfileSosmedDel);
            _ctx.SaveChanges();

            rs.SetSuccessStatus();

            return(rs);
        }
        public IHttpActionResult Edit(TOURIS_TV_USER userView)
        {
            ApiResData             res         = new ApiResData();
            TOURIS_TM_USER         user        = new TOURIS_TM_USER();
            TOURIS_TM_USER_PROFILE userProfile = new TOURIS_TM_USER_PROFILE();
            List <TOURIS_TM_USER_PROFILE_SOSMED> userProfileSosmeds = new List <TOURIS_TM_USER_PROFILE_SOSMED>();

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

                if (userView != null)
                {
                    user.ID                 = userView.ID;
                    user.USER_ID            = userView.USER_ID;
                    user.USER_MAIL          = userView.USER_MAIL;
                    user.USER_NAME          = userView.USER_NAME;
                    user.IS_SUPER_ADMIN     = userView.IS_SUPER_ADMIN;
                    user.LAST_MODIFIED_BY   = userView.LAST_MODIFIED_BY;
                    user.LAST_MODIFIED_TIME = userView.LAST_MODIFIED_TIME;

                    if (userView.TOURIS_TV_USER_PROFILE != null)
                    {
                        userProfile.USER_ID_ID = userView.ID;
                        if (userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().PHOTO_PATH != null)
                        {
                            userProfile.PHOTO_PATH = userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().PHOTO_PATH;
                        }
                        userProfile.GENDER             = userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().GENDER;
                        userProfile.BORN               = userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().BORN;
                        userProfile.ADDRESS            = userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().ADDRESS;
                        userProfile.DESCRIPTION        = userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().DESCRIPTION;
                        userProfile.JOB                = userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().JOB;
                        userProfile.COMPANY            = userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().COMPANY;
                        userProfile.HOBBY              = userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().HOBBY;
                        userProfile.LAST_MODIFIED_BY   = userView.LAST_MODIFIED_BY;
                        userProfile.LAST_MODIFIED_TIME = userView.LAST_MODIFIED_TIME;

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

                                userProfileSosmeds.Add(userProfileSosmed);
                            }
                        }
                    }
                }

                rs = repo.Edit(user, userProfile, userProfileSosmeds);
                if (rs.IsSuccess)
                {
                    rs.SetSuccessStatus();
                }
                else
                {
                    rs.SetErrorStatus(eFunc.fg.SFailed);
                }

                resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Edit, null));
                return(Content(HttpStatusCode.OK, resObj));
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
                resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Edit, new Exception(eFunc.fg.EFailed)));
                return(Content(HttpStatusCode.BadRequest, resObj));
            }
        }