Beispiel #1
0
        public Entity.ActionStatus ManageMasterWidget(Entity.MasterWidget request)
        {
            try
            {
                var dbMasterWidget = Mapper.Configuration.Mapper.Map <Entity.MasterWidget, Model.MasterWidget>(request);
                Entity.ActionStatus actionStatus = new Entity.ActionStatus(true);
                if (request.Guid == null || request.Guid == Guid.Empty)
                {
                    dbMasterWidget.Guid    = Guid.NewGuid();
                    dbMasterWidget.Widgets = RemoveWhiteSpace(Convert.ToString(request.Widgets));

                    dbMasterWidget.IsActive    = true;
                    dbMasterWidget.IsDeleted   = false;
                    dbMasterWidget.CreatedDate = DateTime.Now;
                    dbMasterWidget.CreatedBy   = component.helper.SolutionConfiguration.CurrentUserId;
                    actionStatus      = _masterWidgetRepository.Insert(dbMasterWidget);
                    actionStatus.Data = Mapper.Configuration.Mapper.Map <Model.MasterWidget, Entity.MasterWidget>(actionStatus.Data);
                }
                else
                {
                    var uniqMasterWidget = _masterWidgetRepository.GetByUniqueId(x => x.Guid == dbMasterWidget.Guid);
                    if (uniqMasterWidget == null)
                    {
                        throw new NotFoundCustomException($"{CommonException.Name.NoRecordsFound} : MasterWidget");
                    }
                    if (uniqMasterWidget != null)
                    {
                        uniqMasterWidget.Widgets      = RemoveWhiteSpace(Convert.ToString(request.Widgets));
                        uniqMasterWidget.ModifiedDate = DateTime.Now;
                        uniqMasterWidget.ModifiedBy   = component.helper.SolutionConfiguration.CurrentUserId;
                        actionStatus      = _masterWidgetRepository.Update(uniqMasterWidget);
                        actionStatus.Data = Mapper.Configuration.Mapper.Map <Model.MasterWidget, Entity.MasterWidget>(actionStatus.Data);
                    }
                    else
                    {
                        return(new Entity.ActionStatus
                        {
                            Success = false,
                            Message = "Widget name already exists!",
                            Data = null
                        });
                    }
                }
                return(actionStatus);
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                return(new Entity.ActionStatus
                {
                    Success = false,
                    Message = ex.Message
                });
            }
        }
 public Entity.BaseResponse <Entity.MasterWidget> Manage(Entity.MasterWidget request)
 {
     Entity.BaseResponse <Entity.MasterWidget> response = new Entity.BaseResponse <Entity.MasterWidget>(true);
     try
     {
         var result = _service.ManageMasterWidget(request);
         response.IsSuccess = result.Success;
         response.Message   = result.Message;
         response.Data      = result.Data;
     }
     catch (Exception ex)
     {
         base.LogException(ex);
         return(new Entity.BaseResponse <Entity.MasterWidget>(false, ex.Message));
     }
     return(response);
 }