Пример #1
0
        public async Task <Response> AddContractType(ContractTypeVM contracttype)
        {
            var Dto = Mapper.Map <ContractTypeVM, ContractType>(contracttype);

            ContractType Exist = await _db.ContractTypes.Where(x => x.Type.Trim() == contracttype.Type.Trim()).FirstOrDefaultAsync();

            if (Exist != null)
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoAlreadyExist, (int)Constant.httpStatus.NoContent, 0));
            }

            _db.ContractTypes.Add(Dto);

            int result = await _db.SaveChangesAsync();

            if (result == 1)
            {
                // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result));
            }
        }
Пример #2
0
        public async Task <Response> AddBank(BankVM bank)
        {
            var Dto = Mapper.Map <BankVM, Bank>(bank);

            Bank Exist = await _db.Banks.Where(x => x.Bank1.Trim() == bank.Bank1.Trim()).FirstOrDefaultAsync();

            if (Exist != null)
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoAlreadyExist, (int)Constant.httpStatus.NoContent, 0));
            }

            _db.Banks.Add(Dto);

            int result = await _db.SaveChangesAsync();

            if (result == 1)
            {
                // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result));
            }
        }
Пример #3
0
        public async Task <Response> updateDo(DorderVM dorder)
        {
            try
            {
                Dorder DTO = Mapper.Map <DorderVM, Dorder>(dorder);



                _db.Dorders.Add(DTO);

                int result = await _db.SaveChangesAsync();

                if (result == 1)
                {
                    // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                    return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
                }
                else
                {
                    return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <int> .ResponseStatus(true, e.Message, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Пример #4
0
        public async Task <Response> AddDo(DorderVM dorder)
        {
            var Dto = Mapper.Map <DorderVM, Dorder>(dorder);

            Dorder Exist = await _db.Dorders.Where(x => x.DoNumber == dorder.DoNumber).FirstOrDefaultAsync();

            if (Exist != null)
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoAlreadyExist, (int)Constant.httpStatus.NoContent, -1));
            }

            _db.Dorders.Add(Dto);

            int result = await _db.SaveChangesAsync();

            if (result == 1)
            {
                // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result));
            }
        }
Пример #5
0
        public async Task <Response> RemoveContractType(ContractTypeVM contracttype)
        {
            try
            {
                var DTO = await _db.ContractTypes.Where(x => x.Id == contracttype.Id).FirstOrDefaultAsync();

                _db.ContractTypes.Remove(DTO);

                int result = await _db.SaveChangesAsync();

                if (result == 1)
                {
                    // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                    return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
                }
                else
                {
                    return(GenericResponses <int> .ResponseStatus(true, Constant.MSGFailed, (int)Constant.httpStatus.NoContent, result));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <int> .ResponseStatus(true, e.Message, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Пример #6
0
        public async Task <Response> UpdateContractQty(ContractVM contract)
        {
            try
            {
                Contract DTO = await _db.Contracts.Where(x => x.ContractNo == contract.ContractNo).FirstOrDefaultAsync();

                DTO.TotatQty = (DTO.TotatQty + contract.TotatQty);



                int result = await _db.SaveChangesAsync();

                if (result == 1)
                {
                    // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                    return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
                }
                else
                {
                    return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <int> .ResponseStatus(true, e.Message, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Пример #7
0
        public async Task <Response> GetAllBilties()
        {
            try
            {
                List <BiltyVM> response = new List <BiltyVM>();
                //var users =  _db.Users.Select(x => x).ToList();
                var DTO = await _db.Bilties.ToListAsync();

                //   Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                //   Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());
                response = Mapper.Map <IEnumerable <Bilty>, List <BiltyVM> >(DTO);
                if (response.Count() > 0)
                {
                    return(GenericResponses <IEnumerable <BiltyVM> > .ResponseStatus(false, response.Count() + Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, response));
                }
                else
                {
                    return(GenericResponses <IEnumerable <BiltyVM> > .ResponseStatus(false, Constant.MDGNoRecordFound, (int)Constant.httpStatus.NoContent, response.ToList()));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <DorderVM> .ResponseStatus(true));
            }
        }
Пример #8
0
        // Note: not actually an embed
        internal static async Task RoleEmbedCreate(CommandContext ctx,
                                                   DiscordChannel channel,
                                                   string title,
                                                   DiscordEmoji emoji,
                                                   DiscordRole role)
        {
            if (title.Length > 0)
            {
                DiscordMessage roleMessage = await channel.SendMessageAsync(
                    content : String.Format("{0}\n{1} {2}",
                                            arg0: title,
                                            arg1: EmojiConverter.GetEmojiString(emoji),
                                            arg2: role.Mention));

                var a = roleMessage.CreateReactionAsync(emoji);
                var b = AddMessageToDatabase(roleMessage.Id, role, emoji);

                await Task.WhenAll(a, b);

                await ctx.RespondAsync(
                    embed : Generics.GenericEmbedTemplate(
                        color: Generics.NeutralColor,
                        description: $"Tasks:\nCreate Reaction Success: {a.IsCompletedSuccessfully}\n" +
                        $"Database Success: {a.IsCompletedSuccessfully}",
                        title: @"Create new embed"));
            }
            else
            {
                await GenericResponses.HandleInvalidArguments(ctx);
            }
        }
Пример #9
0
        public async Task <Response> AddBilty(BiltyVM bilty, decimal[] dos)
        {
            var Dto = Mapper.Map <BiltyVM, Bilty>(bilty);



            _db.Bilties.Add(Dto);

            int result = await _db.SaveChangesAsync();

            if (result == 1)
            {
                // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());


                foreach (decimal donumber in dos)
                {
                    BiltyToDo biltyToDoObj = new BiltyToDo();
                    biltyToDoObj.Biltyno  = Dto.BiltyNo;
                    biltyToDoObj.Donumber = donumber;
                    _db.BiltyToDos.Add(biltyToDoObj);
                    int resultDos = await _db.SaveChangesAsync();
                }



                return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result));
            }
        }
Пример #10
0
        public async Task <Response> AddVehicle(VehicleVM vehicle)
        {
            var vehicleDto = Mapper.Map <VehicleVM, vehicle>(vehicle);

            vehicle vehicleExist = await _db.vehicles.Where(x => x.RegNumber.Trim() == vehicle.RegNumber.Trim()).FirstOrDefaultAsync();

            if (vehicleExist != null)
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoAlreadyExist, (int)Constant.httpStatus.NoContent, 0));
            }

            _db.vehicles.Add(vehicleDto);

            int result = await _db.SaveChangesAsync();

            if (result == 1)
            {
                // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result));
            }
        }
Пример #11
0
        public async Task <Response> AddGood(GoodsTypeVM goods)
        {
            var goodsDto = Mapper.Map <GoodsTypeVM, GoodsType>(goods);

            GoodsType goodsExist = await _db.GoodsTypes.Where(x => x.Goods.Trim() == goods.Goods.Trim()).FirstOrDefaultAsync();

            if (goodsExist != null)
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoAlreadyExist, (int)Constant.httpStatus.NoContent, 0));
            }

            _db.GoodsTypes.Add(goodsDto);

            int result = await _db.SaveChangesAsync();

            if (result == 1)
            {
                // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result));
            }
        }
Пример #12
0
        public async Task FilterBase(CommandContext ctx,
                                     string action,
                                     [RemainingText]
                                     string mask = @"")
        {
            // Check if they have the permissions to call this command.
            if (await Permissions.HandlePermissionsCheck(ctx))
            {
                switch (action)
                {
                case "new":
                case "add":
                    if (!(await FilterSystem.HasItem(mask)))
                    {       // The mask doesn't exist already.
                        await FilterSystem.AddMask(ctx, mask);
                    }
                    else
                    {       // The mask does exist.
                        await GenericResponses.SendGenericCommandError(
                            ctx.Channel,
                            ctx.Member.Mention,
                            "Unable to add mask",
                            $"the provided mask `{mask}` exists already as an exclude or mask...");
                    }
                    break;

                case "remove":
                case "delete":
                    if ((await FilterSystem.HasMask(mask)))
                    {       // The mask exists.
                        await FilterSystem.RemoveMask(ctx, mask);
                    }
                    else
                    {       // The mask doesn't exist.
                        await GenericResponses.SendGenericCommandError(
                            ctx.Channel,
                            ctx.Member.Mention,
                            "Unable to remove mask",
                            $"the provided mask `{mask}` does not exist...");
                    }
                    break;

                case "list":
                    await FilterSystem.ListMasks(ctx);

                    break;

                default:     // Invalid arguments.
                    await GenericResponses.HandleInvalidArguments(ctx);

                    break;
                }
            }
        }
Пример #13
0
        public async Task ExcludeBase(CommandContext ctx,
                                      string action,
                                      [RemainingText]
                                      string exclude = @"")
        {
            // Check if they have the permissions to call this command.
            if (await Permissions.HandlePermissionsCheck(ctx))
            {
                switch (action)
                {
                case "new":
                case "add":
                    if (!(await FilterSystem.HasItem(exclude)))
                    {       // The exclude doesn't exist already.
                        await FilterSystem.AddExclude(ctx, exclude);
                    }
                    else
                    {       // The exclude does exist.
                        await GenericResponses.SendGenericCommandError(
                            ctx.Channel,
                            ctx.Member.Mention,
                            "Unable to add exclude",
                            $"the provided exclude `{exclude}` exists already as an exclude or mask...");
                    }
                    break;

                case "remove":
                case "delete":
                    if ((await FilterSystem.HasExclude(exclude)))
                    {       // The exclude  exists.
                        await FilterSystem.RemoveExclude(ctx, exclude);
                    }
                    else
                    {       // The exclude doesn't exist.
                        await GenericResponses.SendGenericCommandError(
                            ctx.Channel,
                            ctx.Member.Mention,
                            "Unable to remove exclude",
                            $"the provided exclude `{exclude}` exists already...");
                    }
                    break;

                case "list":
                    await FilterSystem.ListExcludes(ctx);

                    break;

                default:
                    await GenericResponses.HandleInvalidArguments(ctx);

                    break;
                }
            }
        }
Пример #14
0
        public async Task <Response> GetDoByBilty(decimal biltynumber)
        {
            var DTOBiltyToDo = await _db.BiltyToDos.Where(x => x.Biltyno == biltynumber).ToListAsync();

            if (DTOBiltyToDo != null)
            {
                return(GenericResponses <IEnumerable <BiltyToDo> > .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, DTOBiltyToDo));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoRecordFound, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Пример #15
0
        public async Task SetRimboardChannel(CommandContext ctx, DiscordChannel channel)
        {
            if (await Permissions.HandlePermissionsCheck(ctx))
            {
                Program.UpdateSettings(ref Program.Settings.RimboardChannelId, channel.Id);

                await GenericResponses.SendMessageSettingChanged(
                    channel : ctx.Channel,
                    mention : ctx.Member.Mention,
                    title : @"Rimboard channel changed",
                    valueName : @"Rimboard channel",
                    newVal : channel.Mention);
            }
        }
Пример #16
0
        public async Task SetRimboardWebhook(CommandContext ctx, ulong id)
        {
            if (await Permissions.HandlePermissionsCheck(ctx))
            {
                Program.UpdateSettings(ref Program.Settings.RimboardWebhookId, id);

                await GenericResponses.SendMessageSettingChanged(
                    channel : ctx.Channel,
                    mention : ctx.Member.Mention,
                    title : @"Rimboard webhook id changed",
                    valueName : @"Rimboard webhook id",
                    newVal : id.ToString());
            }
        }
Пример #17
0
        public async Task SetRimboardEmote(CommandContext ctx, DiscordEmoji emote)
        {
            if (await Permissions.HandlePermissionsCheck(ctx))
            {
                Program.UpdateSettings(ref Program.Settings.RimboardEmoticon, new EmojiData(emote));

                await GenericResponses.SendMessageSettingChanged(
                    channel : ctx.Channel,
                    mention : ctx.Member.Mention,
                    title : @"Rimboard emoji changed",
                    valueName : @"Rimboard emoji",
                    newVal : emote.ToString());
            }
        }
Пример #18
0
        public async Task <Response> GetallVehicles()
        {
            try
            {
                List <VehicleVM> response = new List <VehicleVM>();
                //var users =  _db.Users.Select(x => x).ToList();
                var vehiclesDTO = await _db.vehicles.ToListAsync();

                //   Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                //   Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());
                // response = Mapper.Map<IEnumerable<GoodsType>, List<GoodsTypeVM>>(goods);

                foreach (var vehicle in vehiclesDTO)
                {
                    VehicleVM obj = new VehicleVM();
                    obj.Capacity            = vehicle.Capacity;
                    obj.CreatedOn           = vehicle.CreatedOn;
                    obj.EcomID              = vehicle.EcomID;
                    obj.Id                  = vehicle.Id;
                    obj.Manufacturer        = vehicle.Manufacturer;
                    obj.Model               = vehicle.Model;
                    obj.RegNumber           = vehicle.RegNumber;
                    obj.Status              = vehicle.Status;
                    obj.StatusName          = _shareRepo.GetVehicleStatusByID((int)vehicle.Status);
                    obj.Type                = vehicle.Type;
                    obj.TypeName            = _shareRepo.GetVehicleTypeID((int)vehicle.Type);
                    obj.Unit                = vehicle.Unit;
                    obj.UnitName            = _shareRepo.GetUnitByID((int)vehicle.Unit);
                    obj.IsContractorVehicle = vehicle.IsContractorVehicle;
                    obj.ContractorId        = vehicle.ContractorId;

                    response.Add(obj);
                }

                if (response.Count() > 0)
                {
                    return(GenericResponses <IEnumerable <VehicleVM> > .ResponseStatus(false, response.Count() + Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, response));
                }
                else
                {
                    return(GenericResponses <IEnumerable <VehicleVM> > .ResponseStatus(false, Constant.MDGNoRecordFound, (int)Constant.httpStatus.NoContent, response.ToList()));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <VehicleVM> .ResponseStatus(true));
            }
        }
Пример #19
0
        public Response GetallVehicleTypes()
        {
            List <DropDownListModel> Lst = new List <DropDownListModel>();

            foreach (DictionaryEntry entry in VehicleTypes)
            {
                DropDownListModel obj = new DropDownListModel();
                obj.Value = (int)entry.Key;
                obj.Text  = entry.Value.ToString();
                Lst.Add(obj);
                // Console.WriteLine("{0}, {1}", entry.Key, entry.Value);
            }

            return(GenericResponses <List <DropDownListModel> > .ResponseStatus(false, Lst.Count() + Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, Lst));
        }
Пример #20
0
        public Response GetVehicleById(int vehicleId)
        {
            var vehicleDTO = _db.vehicles.Where(x => x.Id == vehicleId).FirstOrDefault();

            //  VehicleVM vehicleVm= Mapper.Map<vehicle, VehicleVM>(vehicleDTO);

            if (vehicleDTO != null)
            {
                return(GenericResponses <vehicle> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, vehicleDTO));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MSGFailed, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Пример #21
0
        public async Task FunAllowed(CommandContext ctx, bool enabled)
        {
            if (await Permissions.HandlePermissionsCheck(ctx))
            {
                Program.UpdateSettings(ref Program.Settings.FunAllowed, enabled);

                string a = GetEnabledDisabled(enabled);
                await GenericResponses.SendMessageSettingChanged(
                    channel : ctx.Channel,
                    mention : ctx.Member.Mention,
                    title : $"Fun {a}",
                    valueName : @"fun allowed",
                    newVal : a);
            }
        }
Пример #22
0
        public Response GetallSelectListContractors()
        {
            var DTO = _db.Contractors.ToList();
            List <DropDownListModel> Lst = new List <DropDownListModel>();

            foreach (var DTobj in DTO)
            {
                DropDownListModel obj = new DropDownListModel();
                obj.Value = (int)DTobj.Id;
                obj.Text  = DTobj.Name;
                Lst.Add(obj);
                // Console.WriteLine("{0}, {1}", entry.Key, entry.Value);
            }

            return(GenericResponses <List <DropDownListModel> > .ResponseStatus(false, Lst.Count() + Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, Lst));
        }
Пример #23
0
        public Response GetallSelectListVehicles()
        {
            var vehiclesDTO = _db.vehicles.ToList();
            List <DropDownListModel> Lst = new List <DropDownListModel>();

            foreach (var vehicle  in vehiclesDTO)
            {
                DropDownListModel obj = new DropDownListModel();
                obj.Value = (int)vehicle.Id;
                obj.Text  = vehicle.RegNumber.ToString();
                Lst.Add(obj);
                // Console.WriteLine("{0}, {1}", entry.Key, entry.Value);
            }

            return(GenericResponses <List <DropDownListModel> > .ResponseStatus(false, Lst.Count() + Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, Lst));
        }
Пример #24
0
        public async Task SetRimboardReactionsRequiredToPin(CommandContext ctx, uint count)
        {
            if (await Permissions.HandlePermissionsCheck(ctx))
            {
                // Clamp it to the max value first so the bot doesn't crash.
                int countInt = (int)Math.Min(count, int.MaxValue);

                Program.UpdateSettings(ref Program.Settings.RimboardPinReactionsNeeded, countInt);

                await GenericResponses.SendMessageSettingChanged(
                    channel : ctx.Channel,
                    mention : ctx.Member.Mention,
                    title : @"Rimboard reactions to pin message required changed",
                    valueName : @"Rimboard reaction to pin requirement",
                    newVal : count.ToString());
            }
        }
Пример #25
0
        public Response ValidateUser(UserVM user)
        {
            UserVM response = new UserVM();
            UserVM r        = new UserVM();
            User   result   = _db.Users.Where(x => x.Email == user.Email && x.Password == user.Password).FirstOrDefault();

            if (result != null)
            {
                // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());
                response = Mapper.Map <User, UserVM>(result);
                return(GenericResponses <UserVM> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, response));
            }
            else
            {
                return(GenericResponses <UserVM> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, null));
            }
        }
Пример #26
0
        public async Task SetMaxWarnLimit(CommandContext ctx, uint months)
        {
            if (await Permissions.HandlePermissionsCheck(ctx))
            {
                // Clamp it to the max value first so the bot doesn't crash.
                int monthsInt = (int)Math.Min(months, int.MaxValue);

                Program.UpdateSettings(ref Program.Settings.MaxActionAgeMonths, monthsInt);

                await GenericResponses.SendMessageSettingChanged(
                    channel : ctx.Channel,
                    mention : ctx.Member.Mention,
                    title : @"Warning threshold changed",
                    valueName : @"warn month limit",
                    newVal : monthsInt.ToString());
            }
        }
Пример #27
0
        public async Task <Response> GetBiltyByDo(decimal donumber)
        {
            var DTOBiltyToDo = await _db.BiltyToDos.Where(x => x.Donumber == donumber).FirstOrDefaultAsync();


            var DTO = await _db.Bilties.Where(x => x.BiltyNo == DTOBiltyToDo.Biltyno).FirstOrDefaultAsync();

            if (DTO != null)
            {
                var Obj = Mapper.Map <Bilty, BiltyVM>(DTO);

                return(GenericResponses <BiltyVM> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, Obj));
            }
            else
            {
                return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoRecordFound, (int)Constant.httpStatus.NoContent, 0));
            }
        }
Пример #28
0
 public async Task RoleEmbedCreate(CommandContext ctx,
                                   DiscordChannel channel,
                                   DiscordEmoji emoji,
                                   DiscordRole role,
                                   [RemainingText]
                                   string title)
 {
     if (await Permissions.HandlePermissionsCheck(ctx))
     {
         if (!(title is null) && title.Length > 0)
         {
             await RoleRequestSystem.RoleEmbedCreate(ctx, channel, title, emoji, role);
         }
         else
         {
             await GenericResponses.HandleInvalidArguments(ctx);
         }
     }
Пример #29
0
        public async Task <Response> GetALLParties()
        {
            try
            {
                List <PartyVM> response = new List <PartyVM>();
                //var users =  _db.Users.Select(x => x).ToList();
                var DTO = await _db.Parties.ToListAsync();

                foreach (var party in DTO)
                {
                    PartyVM obj = new PartyVM();
                    obj.ConectPerson = party.ConectPerson;
                    obj.CreatedOn    = party.CreatedOn;
                    obj.EcomID       = party.EcomID;
                    obj.Id           = party.Id;
                    obj.IsSubParty   = party.IsSubParty;
                    obj.ParentId     = party.ParentId;
                    obj.Phone        = party.Phone;
                    obj.Party1       = party.Party1;
                    if (party.ParentId != null && party.ParentId != 0)
                    {
                        obj.ParentPartyName = GetPartyById((int)party.ParentId).Party1;
                    }
                    response.Add(obj);
                }

                //   Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());

                //   Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>());
                // response = Mapper.Map<IEnumerable<Expense>, List<ExpenseVM>>(DTO);
                if (response.Count() > 0)
                {
                    return(GenericResponses <IEnumerable <PartyVM> > .ResponseStatus(false, response.Count() + Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, response));
                }
                else
                {
                    return(GenericResponses <IEnumerable <PartyVM> > .ResponseStatus(false, Constant.MDGNoRecordFound, (int)Constant.httpStatus.NoContent, response.ToList()));
                }
            }
            catch (Exception e)
            {
                return(GenericResponses <PartyVM> .ResponseStatus(true));
            }
        }
Пример #30
0
        public async Task ReminderBase(CommandContext ctx,
                                       string action,
                                       [RemainingText]
                                       string args = @"")
        {
            // Check if they have the permissions to call this command.
            if (await Permissions.HandlePermissionsCheck(ctx))
            {
                switch (action)
                {
                case "new":
                case "add":
                    await ReminderSystem.AddReminder(ctx, args);

                    break;

                case "remove":
                case "delete":
                    // Check if this is even a reminder.

                    Reminder possibleReminder = await ReminderSystem.GetReminderFromDatabase(args);

                    if (!possibleReminder.Equals(Reminder.Invalid))
                    {       // It's a reminder.
                        await ReminderSystem.RemoveReminder(ctx, possibleReminder);
                    }
                    else
                    {       // It's not a reminder.
                        await GenericResponses.SendGenericCommandError(
                            ctx.Channel,
                            ctx.Member.Mention,
                            "Unable to remove reminder",
                            $"The reminder id `{args}` does not exist...");
                    }
                    break;

                case "list":
                    await ReminderSystem.ListReminders(ctx);

                    break;
                }
            }
        }