Ejemplo n.º 1
0
        public IndexUI()
        {
            //UnitOfWork switchUnitOfWork = new UnitOfWork();
            ChannelDAO chanelDao = new ChannelDAO();

            AddSection()
            .StretchFields(50)
            .WithTitle("Search Channels")
            .IsCollapsible()
            .IsFramed()
            .WithColumns(new List <Column>()
            {
                new Column(new List <IField>()
                {
                    Map(x => x.Name).AsSectionField <TextBox>().TextFormatIs("^[A-Za-z0-9]"),
                    Map(x => x.Code).AsSectionField <TextBox>().TextFormatIs(@"^[0-9]{2}$"),
                    AddSectionButton()
                    .ApplyMod <IconMod>(x => x.WithIcon(Ext.Net.Icon.Magnifier))
                    .WithText("Search")
                    .UpdateWith(x =>
                    {
                        return(x);
                    })
                })
            });

            HasMany(x => x.AllChannels)
            .As <Grid>()
            .ApplyMod <IconMod>(x => x.WithIcon(Ext.Net.Icon.Link))
            .ApplyMod <ViewDetailsMod>(y => y.Popup <DetailsUI>("Channel Details")
                                       .PrePopulate <Channel, Channel>(x => x))
            .Of <Channel>()
            .WithColumn(x => x.Name)
            .WithColumn(x => x.Code)
            .WithColumn(x => x.Description)
            .WithRowNumbers()
            .IsPaged <ViewChannelUIModel>(10, (x, e) =>
            {
                int totalCount = 0;
                try
                {
                    var results   = (String.IsNullOrEmpty(x.Name) && String.IsNullOrEmpty(x.Code)) ? chanelDao.Get() : chanelDao.Search(x, e.Start, e.Limit, out totalCount, a => a.Name.ToLower().Contains(x.Name.ToLower()) && a.Code.Contains(x.Code));
                    x.AllChannels = results.ToList();
                }
                catch (Exception ex)
                {
                    string msg = ex.Message + " Inner Exception: " + ex.InnerException;
                    MessageLogger.LogError(msg);
                }

                e.TotalCount = totalCount;
                return(x);
            })
            .LabelTextIs("Channels");
        }
Ejemplo n.º 2
0
        public static Message?Create(DataRow dataRow)
        {
            var channelDataRows = ChannelDAO.Get(dataRow.Field <int>("channel_id")).Rows;

            if (channelDataRows.Count is 0)
            {
                return(null);
            }

            var userDataRows = UserDAO.GetWithId(dataRow.Field <int>("user_id")).Rows;

            if (userDataRows.Count is 0)
            {
                return(null);
            }

            var parentMessageId = dataRow.Field <object>("parent_message_id");

            Message?parentMessage = null;

            if (parentMessageId != null)
            {
                var MessageDataRows = MessageDAO.GetWithId((int)parentMessageId).Rows;
                if (MessageDataRows.Count is 0)
                {
                    return(null);
                }

                parentMessage = Create(MessageDataRows[0]);
            }

            return(new Message(
                       dataRow.Field <int>("id"),
                       ChannelFactory.Create(channelDataRows[0]),
                       UserFactory.Create(userDataRows[0]),
                       dataRow.Field <string>("text"),
                       dataRow.Field <DateTime>("time"),
                       parentMessage));
        }
 public ChannelManager()
 {
     _db = new ChannelDAO();
 }
 public ChannelManager(ChannelDAO db)
 {
     _db = db;
 }
Ejemplo n.º 5
0
        public AddUI()
        {
            //UnitOfWork switchUnitOfWork = new UnitOfWork();
            ChannelDAO chanelDao = new ChannelDAO();

            WithTitle("Add new Channel");

            Map(x => x.Name).As <TextBox>()
            .WithLength(35)
            .LabelTextIs("Channel Name")
            .Required()
            .TextFormatIs("^[A-Za-z0-9]");

            Map(x => x.Code).As <TextBox>()
            .WithLength(35)
            .LabelTextIs("Channel Code")
            .Required()
            .TextFormatIs(@"^[0-9]{2}$");

            Map(x => x.Description).As <TextBox>()
            .WithLength(50)
            .LabelTextIs("Description")
            .Required()
            .TextFormatIs("^[ a-zA-Z0-9]+$");

            string errorMsg = "";

            AddButton()
            .WithText("Add Channel")
            .SubmitTo(x =>
            {
                bool flag = false;
                try
                {
                    //check for uniqueness
                    //ChannelDAO channelDAO = new ChannelDAO();
                    if (chanelDao.isUniqueName(x.Name) && chanelDao.isUniqueCode(x.Code))
                    {
                        Channel channel = new Channel {
                            DateCreated = DateTime.Now, DateModified = DateTime.Now, Name = x.Name, Code = x.Code, Description = x.Description
                        };
                        chanelDao.Insert(channel);
                        //switchUnitOfWork.SaveChanges();
                        flag = true;
                    }
                    else
                    {
                        errorMsg += "Channel name and code must be unique";
                        MessageLogger.LogError(errorMsg);
                        flag = false;
                    }
                }
                catch (Exception ex)
                {
                    flag       = false;
                    errorMsg  += "Unable to add channel";
                    string msg = "Message: " + ex.Message + "   InnerException = " + ex.InnerException;
                    MessageLogger.LogError(msg);
                }
                return(flag);   //Success
            })
            .OnSuccessDisplay(x =>
            {
                return("Channel Added Successfully");
            })
            .OnFailureDisplay(x => { return("Unable to add Channel.\n  " + errorMsg); });;
        }
Ejemplo n.º 6
0
        public CreateComboUI()
        {
            // UnitOfWork unitOfWork = new UnitOfWork();
            ChannelDAO channelDao = new ChannelDAO();
            string     msg        = "";

            WithTitle("Create a new Transaction type-Channel-Fee Combo");

            Map(x => x.Name).As <TextBox>()
            .WithLength(35)
            .LabelTextIs("Combo Name")
            .Required()
            .TextFormatIs("^[ a-zA-Z0-9]+$");

            Map(x => x.TransactionType).As <DropDownList>()
            .Of(() => { return(new TransactionTypeDAO().Get().ToList()); })
            .ListOf(x => x.Name, x => x.ID).WithEditableText()
            .Required()
            .LabelTextIs("Transaction Type");

            Map(x => x.Channel).As <DropDownList>()
            .Of(() => { return(channelDao.Get().ToList()); })
            .ListOf(x => x.Name, x => x.ID).WithEditableText()
            .Required()
            .LabelTextIs("Channel");

            Map(x => x.Fee).As <DropDownList>()
            .Of(() => { return(new FeeDAO().Get().ToList()); })
            .ListOf(x => x.Name, x => x.ID).WithEditableText()
            .Required()
            .LabelTextIs("Fee");

            AddButton()
            .ApplyMod <IconMod>(x => x.WithIcon(Ext.Net.Icon.Disk))
            .WithText("Create")
            .SubmitTo(x =>
            {
                try
                {
                    if (!new ComboDAO().isUniqueName(x.Name))
                    {
                        msg += "Combo name must be unique";
                        return(false);
                    }
                    Combo combo = new Combo {
                        TransactionType = x.TransactionType, Fee = x.Fee, Channel = x.Channel, Name = x.Name, DateCreated = DateTime.Now, DateModified = DateTime.Now
                    };
                    new ComboDAO().Insert(combo);
                    return(true);
                }
                catch (Exception ex)
                {
                    msg          += "An error occured";
                    string logMsg = "Message= " + ex.Message + " Inner Exception= " + ex.InnerException;
                    MessageLogger.LogError(logMsg);
                    return(false);
                }
            })
            .OnSuccessDisplay(x =>
            {
                return("Combo" + "" + x.Name + " created successfully.");
            })
            .OnFailureDisplay(s => String.Format("Error: {0} ", msg))
            .CssClassIs("btn btn-default");
        }
Ejemplo n.º 7
0
 public static List <Channel> GetChannels(int userId)
 {
     return(ChannelDAO.GetLoginUserChannels(userId));
 }
Ejemplo n.º 8
0
        public EditUI()
        {
            //UnitOfWork switchUnitOfWork = new UnitOfWork();
            ChannelDAO chanelDao = new ChannelDAO();

            string msg = "";

            AddSection()
            .IsFramed()
            .WithTitle("Edit Channel")
            .WithColumns(new List <Column>
            {
                new Column(
                    new List <IField> {
                    Map(x => x.Name)
                    .AsSectionField <TextBox>()
                    .WithLength(50).LabelTextIs("Name")
                    .Required().TextFormatIs("")
                    .TextFormatIs("^[A-Za-z0-9]"),
                    Map(x => x.Code)
                    .AsSectionField <TextBox>()
                    .TextFormatIs(TextFormat.numeric)
                    .WithLength(60).LabelTextIs("Code").Required()
                    .TextFormatIs(@"^[0-9]{2}$"),
                    Map(x => x.Description)
                    .AsSectionField <TextBox>()
                    .WithLength(60).LabelTextIs("Description").Required()
                    .TextFormatIs("^[ a-zA-Z0-9]+$"),


                    Map(x => x.ID).AsSectionField <TextLabel>().ApplyMod <VisibilityMod>(m => m.Hide <Channel>(h => { return(true); })),
                }),
            })
            .WithFields(new List <IField> {
                AddSectionButton()
                .SubmitTo(x =>
                {
                    try
                    {
                        //ChannelDAO channelDAO = new ChannelDAO();
                        Channel channel = chanelDao.GetById(x.ID);

                        //check for uniqueness
                        if (!chanelDao.isUniqueName(channel.Name, x.Name))
                        {
                            msg += "Name must be unique";
                            return(false);
                        }
                        if (!chanelDao.isUniqueCode(channel.Code, x.Code))
                        {
                            msg += "Code must be unique";
                            return(false);
                        }

                        channel.Name         = x.Name;
                        channel.Code         = x.Code;
                        channel.Description  = x.Description;
                        channel.DateModified = DateTime.Now;

                        chanelDao.Update(channel);
                        //switchUnitOfWork.SaveChanges();
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        msg          += "An error occured";
                        string logMsg = "Message= " + ex.Message + " Inner Exception= " + ex.InnerException;
                        MessageLogger.LogError(logMsg);
                        return(false);
                    }
                })
                .ConfirmWith(s => String.Format("Update Channel type {0} ", s.Name)).WithText("Update")
                .OnSuccessDisplay(s => String.Format("Channel \"{0}\" has been successfuly editted ", s.Name))
                .OnFailureDisplay(s => String.Format("Error editting!\n   {0} ", msg))
            });
        }
Ejemplo n.º 9
0
        /// <summary> Retrieves Entity rows in a datatable which match the specified filter. It will always create a new connection to the database.</summary>
        /// <param name="selectFilter">A predicate or predicate expression which should be used as filter for the entities to retrieve.</param>
        /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query.</param>
        /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param>
        /// <param name="relations">The set of relations to walk to construct to total query.</param>
        /// <param name="pageNumber">The page number to retrieve.</param>
        /// <param name="pageSize">The page size of the page to retrieve.</param>
        /// <returns>DataTable with the rows requested.</returns>
        public static DataTable GetMultiAsDataTable(IPredicate selectFilter, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations, int pageNumber, int pageSize)
        {
            ChannelDAO dao = DAOFactory.CreateChannelDAO();

            return(dao.GetMultiAsDataTable(maxNumberOfItemsToReturn, sortClauses, selectFilter, relations, pageNumber, pageSize));
        }
Ejemplo n.º 10
0
 public void GetAvailableByUserid(ObservableCollection <Channel> Channels, int userId)
 {
     ChannelDAO.GetAvailableByUserid(Channels, userId);
 }