Esempio n. 1
0
        public BsJsonResult Update(ContributorDetailsEditable model, int objId, EditComponents componentId)
        {
            var msg      = string.Empty;
            var status   = BsResponseStatus.Success;
            var html     = string.Empty;
            var rowsHtml = string.Empty;

            try
            {
                ClearModelState(ModelState, componentId);

                if (ModelState.IsValid)
                {
                    var detailsModel = _gridRepository.Update(model, objId, componentId);

                    //simulate exception
                    if (objId == 6)
                    {
                        throw new Exception("This is how an exception message is displayed inside row details");
                    }

                    switch (componentId)
                    {
                    case EditComponents.Identity:
                        html = this.BsRenderPartialView("Grid/Details/_IdentityReadonly", detailsModel.Identity);
                        break;

                    case EditComponents.ProjectRelated:
                        html = this.BsRenderPartialView("Grid/Details/_ProjectRelatedReadonly", detailsModel.ProjectRelated);
                        break;
                    }

                    var rowModel = _gridRepository.ReadRow(objId);

                    var viewModel = _gridRepository.ToBsGridViewModel(rowModel, true).Wrap <ContributorsViewModel>(x => x.Grid);

                    rowsHtml = this.BsRenderPartialView("Grid/_Grid", viewModel);
                }
            }
            catch (Exception ex)
            {
                msg    = "<strong>" + Resource.ServerError + "!</strong> " + ex.Message;
                status = BsResponseStatus.ServerError;
            }

            return(new BsJsonResult(new
            {
                Html = html,
                RowsHtml = rowsHtml
            }, status, msg));
        }