public OutputModel GetDetailUser(int uid)
        {
            OutputModel output = new OutputModel();

            try
            {
                var data = db.tblM_User.Where(p => p.UserID == uid &&
                                              p.isVerified == 1 &&
                                              p.isActive == 1).Select(p => p).FirstOrDefault();

                output.status  = "success";
                output.message = null;
                output.data    = data;
            }
            catch (Exception ex)
            {
                output.status  = "error";
                output.message = ex.Message;
                output.data    = null;
            }

            return(output);
        }
        public OutputModel GetAllCatering(int merchantId)
        {
            OutputModel output = new OutputModel();

            try
            {
                DateTime dt   = DateTime.Now.StartOfWeek(DayOfWeek.Monday);
                var      data = db_masakin.tblT_Catering.Where(p => p.MerchantID == merchantId &&
                                                               p.DateFirst >= dt &&
                                                               p.isActive == 1).Select(p => p).ToList();

                output.status  = "success";
                output.message = null;
                output.data    = data;
            }
            catch (Exception ex)
            {
                output.status  = "error";
                output.message = ex.Message;
                output.data    = null;
            }
            return(output);
        }
        private async void _create(object obj)
        {
            bool isgoodlink = LinksCheck();

            if (isgoodlink)
            {
                UpdateProgress("连接mora...", 0);
                string packagelink = await MoraHelper.GetMoraPackageLinkAsync(MoraLink);

                UpdateProgress("读取信息...", 1);
                MoraJsonObjectModel moraJsonObject = await MoraHelper.GetMoraJsonObjectAsync(packagelink);

                UpdateProgress("生成主题...", 2);
                OutputModel output = new OutputModel(moraJsonObject, DownloadLinkCollection, CertificationLink, MoraLink);
                OutTitle = output.OutputTitle();
                OutBody  = output.OutputBody(_template);
                UpdateProgress("完成生成", 3);
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("mora链接错误!");
            }
        }
Esempio n. 4
0
    public static void Write(OutputModel outputModel, DatabasePlan databasePlan, PartitionPlan partitionPlan)
    {
        var s = $@"
namespace {databasePlan.Namespace};

public class {partitionPlan.CreateClassName}
{{
    protected virtual {databasePlan.Namespace}.{partitionPlan.ClassName} {partitionPlan.ClassName} {{ get; }} = default!;

    /// <summary>Mocking constructor</summary>
    protected {partitionPlan.CreateClassName}() {{ }}

    internal protected {partitionPlan.CreateClassName}({databasePlan.Namespace}.{partitionPlan.ClassName} {partitionPlan.ClassNameArgument})
    {{
        this.{partitionPlan.ClassName} = {partitionPlan.ClassNameArgument} ?? throw new System.ArgumentNullException(nameof({partitionPlan.ClassNameArgument}));
    }}

{string.Concat(partitionPlan.Documents.Select(x => Create(partitionPlan, x)))}
}}
";

        outputModel.Context.AddSource($"partition_{partitionPlan.CreateClassName}.cs", s);
    }
Esempio n. 5
0
        public virtual ApiResult GetAllWithPaging(PagingParams pagingParams)
        {
            try
            {
                _logger.LogInformation($"GetAllWithPaging from the {typeof(T)} table");
                var pagingLinks = _service.GetService <IPagingLinks <T> >();

                var model = new PagedList <T>(
                    GetQueryable(), pagingParams.PageNumber, pagingParams.PageSize);

                Response.Headers.Add("X-Pagination", model.GetHeader().ToJson());

                var outputModel = new OutputModel <T>
                {
                    Paging = model.GetHeader(),
                    Links  = pagingLinks.GetLinks(model),
                    Items  = model.List.Select(m => m).ToList(),
                };

                return(new ApiResult
                {
                    StatusCode = StatusCodes.Status200OK,
                    Message = "Success",
                    Data = outputModel
                });
            }
            catch (Exception ex)
            {
                _logger.LogError($"GetAllWithPaging error from the {typeof(T)} table. Data: {String.Join(',', pagingParams.GetType().GetProperties().Select(x => $" - {x.Name} : {x.GetValue(pagingParams)} - ").ToList())} exception:{ex}");
                return(new ApiResult
                {
                    StatusCode = StatusCodes.Status500InternalServerError,
                    Message = $"Error:{ex.Message}",
                    Data = null
                });
            }
        }
        public OutputModel UpdateMenu([FromBody] tblM_Menu menu)
        {
            OutputModel output = new OutputModel();

            try
            {
                var data = db_masakin.tblM_Menu.Where(p => p.MenuID == menu.MenuID &&
                                                      p.MerchantID == menu.MerchantID).FirstOrDefault();

                if (data != null)
                {
                    data.Name         = menu.Name;
                    data.Description  = menu.Description;
                    data.Price        = menu.Price;
                    data.ImageURL     = menu.ImageURL;
                    data.ThumbnailURL = menu.ThumbnailURL;
                    db_masakin.SaveChanges();

                    output.status  = "success";
                    output.message = null;
                    output.data    = data;
                }
                else
                {
                    output.status  = "failed";
                    output.message = "Menu not found";
                    output.data    = null;
                }
            }
            catch (Exception ex)
            {
                output.status  = "error";
                output.message = ex.Message;
                output.data    = null;
            }
            return(output);
        }
        public static List <OutputModel> BuildOutputModel(Dictionary <string, Dictionary <string, Dictionary <DateTime?, int> > > dictionary)
        {
            var listOutput = new List <OutputModel>();

            foreach (var t in dictionary.Keys)
            {
                var measure = t;
                foreach (var r in dictionary[t].Keys)
                {
                    var port = r;
                    var b    = dictionary[t][r];
                    foreach (var k in b)
                    {
                        var average = AnalysisHelper.CalculateAverage(k.Key, b);
                        var model   = new OutputModel {
                            Date = k.Key, Value = k.Value, Border = port, Measure = measure, Average = average
                        };
                        listOutput.Add(model);
                    }
                }
            }

            return(listOutput);
        }
Esempio n. 8
0
    static void Validate(OutputModel outputModel, ClassModel classModel, PropertyModel model)
    {
        var symbol = model.PropertySymbol;

        if (model.UseDefaultAttribute is not null)
        {
            if (symbol.IsStatic)
            {
                outputModel.Report(Diagnostics.Errors.UseDefaultStatic, symbol);
            }
            if (!classModel.IsDbDoc)
            {
                outputModel.Report(Diagnostics.Errors.UseDefaultDbDoc, symbol);
            }
            if (!outputModel.CanIncludeProperty(symbol))
            {
                outputModel.Report(Diagnostics.Warnings.UseDefaultIgnored, symbol);
            }
            if (symbol.Type.IsReferenceType && symbol.Type.NullableAnnotation != NullableAnnotation.Annotated)
            {
                outputModel.Report(Diagnostics.Errors.UseDefaultNullable, symbol);
            }
        }
    }
Esempio n. 9
0
    public static void Write(OutputModel outputModel, DatabasePlan databasePlan, PartitionPlan partitionPlan)
    {
        var s = $@"
namespace {databasePlan.Namespace};

public class {partitionPlan.QueryClassName} : Cosmogenesis.Core.DbQueryBase
{{
    protected virtual {databasePlan.Namespace}.{databasePlan.DbClassName} {databasePlan.DbClassName} {{ get; }} = default!;
    protected virtual {databasePlan.Namespace}.{partitionPlan.QueryBuilderClassName} {partitionPlan.QueryBuilderClassName} {{ get; }} = default!;

    /// <summary>Mocking constructor</summary>
    protected {partitionPlan.QueryClassName}() {{ }}

    internal protected {partitionPlan.QueryClassName}(
        {databasePlan.Namespace}.{databasePlan.DbClassName} {databasePlan.DbClassNameArgument},
        {databasePlan.Namespace}.{partitionPlan.QueryBuilderClassName} {partitionPlan.QueryBuilderClassNameArgument})
        : base(
            dbBase: {databasePlan.DbClassNameArgument},
            queryBuilder: {partitionPlan.QueryBuilderClassNameArgument})
    {{
        this.{databasePlan.DbClassName} = {databasePlan.DbClassNameArgument} ?? throw new System.ArgumentNullException(nameof({databasePlan.DbClassNameArgument}));
        this.{partitionPlan.QueryBuilderClassName} = {partitionPlan.QueryBuilderClassNameArgument} ?? throw new System.ArgumentNullException(nameof({partitionPlan.QueryBuilderClassNameArgument}));
    }}

{string.Concat(partitionPlan.Documents.Select(x => Query(databasePlan, partitionPlan, x)))}
{Unions(databasePlan, partitionPlan)}
}}
";

        if (partitionPlan.Unions.Any())
        {
            QueryUnionsWriter.Write(outputModel, databasePlan, partitionPlan);
        }

        outputModel.Context.AddSource($"partition_{partitionPlan.QueryClassName}.cs", s);
    }
Esempio n. 10
0
 static void AddImplicitPartitions(OutputModel outputModel, OutputPlan outputPlan)
 {
     foreach (var kvp in outputPlan.DatabasePlansByClass)
     {
         var classModel    = kvp.Key;
         var databasePlans = kvp.Value;
         if (classModel.PartitionAttribute is not null)
         {
             var name = classModel.PartitionAttribute.Name;
             foreach (var databasePlan in databasePlans)
             {
                 if (!databasePlan.PartitionPlansByName.ContainsKey(name))
                 {
                     var getPk = classModel.Methods
                                 .Where(x => x.MethodSymbol.Name == "GetPk")
                                 .Where(x => x.MethodSymbol.IsStatic)
                                 .Where(x => x.MethodSymbol.ReturnType.SpecialType == SpecialType.System_String)
                                 .Where(x => x.MethodSymbol.DeclaredAccessibility.IsAccessible())
                                 .ToList();
                     if (getPk.Count == 0)
                     {
                         outputModel.Report(Diagnostics.Errors.NoGetPk, classModel.ClassSymbol);
                     }
                     else if (getPk.Count > 1)
                     {
                         outputModel.Report(Diagnostics.Errors.MultipleGetPk, classModel.ClassSymbol);
                     }
                     else
                     {
                         AddPartitionDefinition(outputModel, databasePlan, getPk[0], name);
                     }
                 }
             }
         }
     }
 }
Esempio n. 11
0
        internal async Task <OutputModel> UserRegistrationFromDynamoDb(InputModel inputModel)
        {
            OutputModel outputModel = null;
            Document    RegisteredUser;

            Int64 UserGuid = Convert.ToInt64(DateTime.Now.ToString("yyyyMMddHHmmssfff"));

            AwsDynamoDbCommon awsDynamoDbCommon = new AwsDynamoDbCommon();

            RegisteredUser = await awsDynamoDbCommon.GetItemOnPrimaryKeyString(inputModel.chatRegisterUserModel.UserName,
                                                                               AwsDynamoDbCommon.AwsDynamoDbTables.tbl_ChatRegistration_Users.ToString());

            if (RegisteredUser == null)
            {
                RegisteredUser = new Document();

                RegisteredUser["UserName"] = inputModel.chatRegisterUserModel.UserName;
                RegisteredUser["UserId"]   = UserGuid;

                await awsDynamoDbCommon.PutItemInTable(RegisteredUser, AwsDynamoDbCommon.AwsDynamoDbTables.tbl_ChatRegistration_Users.ToString());
            }

            outputModel = new OutputModel()
            {
                ChatRegisterUserOutput = new ChatRegisterUserModel()
                {
                    UserName = RegisteredUser["UserName"],
                    UserId   = RegisteredUser["UserId"].AsLong(),
                },

                ExecutionalStatus = ExecutionStatusEnums.ExecutionStatus.Success,
            };


            return(outputModel);
        }
Esempio n. 12
0
 static void Validate(OutputModel outputModel, ClassModel classModel, MethodModel model)
 {
 }
Esempio n. 13
0
 public static void Build(OutputModel outputModel, ClassModel classModel, AttributeData attributeData) => classModel.MutableAttribute = new();
Esempio n. 14
0
        private void ExcecuteMethod <T>(CallDelegate <RequestParams, OutputModel <T>, bool> method, RequestParams @params, out OutputModel <T> outputModel)
        {
            outputModel = null;

            for (int i = 0; i < 2; i++)
            {
                if (method(@params, out outputModel))
                {
                    break;
                }
                else
                {
                    if (outputModel.Response.Status == Status.InvalidSession)
                    {
                        // Login and retrieve session token
                        if (!Login(out var response))
                        {
                            throw new Exception($"Invalid session and couldn't refresh. {response.Message}");
                        }
                    }
                    else
                    {
                        throw new Exception("Unknown error.");
                    }
                }
            }
        }
Esempio n. 15
0
 public OutputViewModel(Person person)
 {
     Model = new OutputModel(person);
     EditPersonInfo(person);
 }
Esempio n. 16
0
    public static void Write(OutputModel outputModel, DatabasePlan databasePlan)
    {
        var s = $@"
namespace {databasePlan.Namespace};

public class {databasePlan.DbClassName} : Cosmogenesis.Core.DbBase
{{
    /// <summary>Mocking constructor</summary>
    protected {databasePlan.DbClassName}() {{ }}
        
    public {databasePlan.DbClassName}(
        Microsoft.Azure.Cosmos.Container container, 
        Cosmogenesis.Core.DbSerializerBase? serializer = null, 
        bool isReadOnly = false,
        bool validateStateBeforeSave = true)
        : base(
            container: container, 
            serializer: serializer ?? {databasePlan.Namespace}.{databasePlan.SerializerClassName}.Instance, 
            isReadOnly: isReadOnly, 
            validateStateBeforeSave: validateStateBeforeSave)
    {{
    }}

    {databasePlan.Namespace}.{databasePlan.PartitionsClassName}? partition;
    public virtual {databasePlan.Namespace}.{databasePlan.PartitionsClassName} Partition => this.partition ??= new(this);

    internal new System.Threading.Tasks.Task<T?> ReadByIdAsync<T>(
        string id, 
        Microsoft.Azure.Cosmos.PartitionKey partitionKey, 
        string type) where T : Cosmogenesis.Core.DbDoc =>
        base.ReadByIdAsync<T>(
            id: id, 
            partitionKey: partitionKey, 
            type: type);

    internal new System.Threading.Tasks.Task<T?[]> ReadByIdsAsync<T>(
        System.Collections.Generic.IEnumerable<string> ids, 
        Microsoft.Azure.Cosmos.PartitionKey partitionKey, 
        string type) where T : Cosmogenesis.Core.DbDoc =>
        base.ReadByIdsAsync<T>(
            ids: ids, 
            partitionKey: partitionKey, 
            type: type);

    internal new System.Threading.Tasks.Task<Cosmogenesis.Core.DbDoc?> ReadByIdAsync(
        string id, 
        Microsoft.Azure.Cosmos.PartitionKey partitionKey) =>
        base.ReadByIdAsync(
            id: id, 
            partitionKey: partitionKey);

    internal new System.Threading.Tasks.Task<Cosmogenesis.Core.DbDoc?[]> ReadByIdsAsync(
        System.Collections.Generic.IEnumerable<string> ids,
        Microsoft.Azure.Cosmos.PartitionKey partitionKey) =>
        base.ReadByIdsAsync(
            ids: ids, 
            partitionKey: partitionKey);

    {databasePlan.Namespace}.{databasePlan.QueryBuilderClassName}? crossPartitionQueryBuilder;
    /// <summary>
    /// Methods to build a cross-partition query for later execution.
    /// </summary>
    public virtual {databasePlan.Namespace}.{databasePlan.QueryBuilderClassName} CrossPartitionQueryBuilder => this.crossPartitionQueryBuilder ??= new(this);

    {databasePlan.Namespace}.{databasePlan.QueryClassName}? crossPartitionQuery;
    /// <summary>
    /// Methods to execute cross-partition queries.
    /// </summary>
    public virtual {databasePlan.Namespace}.{databasePlan.QueryClassName} CrossPartitionQuery => this.crossPartitionQuery ??= new(this, this.CrossPartitionQueryBuilder);

    {databasePlan.Namespace}.{databasePlan.ReadClassName}? read;
    /// <summary>
    /// Methods to read documents by providing pk & id.
    /// </summary>
    public virtual {databasePlan.Namespace}.{databasePlan.ReadClassName} Read => this.read ??= new(this);
}}
";

        outputModel.Context.AddSource($"db_{databasePlan.DbClassName}.cs", s);


        ConverterWriter.Write(outputModel, databasePlan);
        SerializerWriter.Write(outputModel, databasePlan);
        TypesWriter.Write(outputModel, databasePlan);

        DbReadWriter.Write(outputModel, databasePlan);
        DbQueryWriter.Write(outputModel, databasePlan);
        DbQueryBuilderWriter.Write(outputModel, databasePlan);

        PartitionsWriter.Write(outputModel, databasePlan);

        BatchHandlersWriter.Write(outputModel, databasePlan);
        ChangeFeedProcessorWriter.Write(outputModel, databasePlan);
    }
Esempio n. 17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="input"></param>
        /// <param name="output"></param>
        public static void Perfrom(ContextModel context, InputModel input, OutputModel output)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            if (output == null)
            {
                throw new ArgumentNullException("output");
            }

            if (null != input.InfoDisplay.MemorySprite.Bitmap)
            {
                // 列数と行数。
                int nCols = (int)input.InfoDisplay.MemorySprite.CountcolumnResult;
                int nRows = (int)input.InfoDisplay.MemorySprite.CountrowResult;

                // ファイル名の頭。
                StringBuilder s1 = new StringBuilder();
                {
                    s1.Append(Application.StartupPath);
                    s1.Append("\\ScreenShot\\");

                    DateTime now = System.DateTime.Now;
                    s1.Append(now.Year);
                    s1.Append("_");
                    s1.Append(now.Month);
                    s1.Append("_");
                    s1.Append(now.Day);
                    s1.Append("_");
                    s1.Append(now.Hour);
                    s1.Append("_");
                    s1.Append(now.Minute);
                    s1.Append("_");
                    s1.Append(now.Second);
                    s1.Append("_");
                    s1.Append(now.Millisecond);
                }


                for (int nRow = 1; nRow <= nRows; nRow++)
                {
                    for (int nCol = 1; nCol <= nCols; nCol++)
                    {
                        int nCell = (nRow - 1) * nCols + nCol;
                        System.Console.WriteLine("r" + nRow + " c" + nCol + " nCell" + nCell + "  nRows" + nRows + " nCols" + nCols);


                        context.UcCanvas.CropForceTxt.Text = nCell.ToString();

                        Bitmap bm = ImageHelper.CreateSaveImage(
                            input.InfoDisplay,
                            input.InfoCheckBox,
                            context.UcCanvas
                            );



                        // ファイル名を適当に作成。
                        StringBuilder s = new StringBuilder();
                        {
                            s.Append(s1.ToString());
                            s.Append("_c");
                            s.Append(nCell.ToString());
                            s.Append(".png");
                        }

                        string file = s.ToString();
                        if (!Directory.Exists(Directory.GetParent(file).Name))
                        {
                            // ScreenShot フォルダーがなければ、作ります。
                            Directory.CreateDirectory(Directory.GetParent(file).Name);
                        }

                        bm.Save(file, System.Drawing.Imaging.ImageFormat.Png);
                    }
                }
            }
        }
Esempio n. 18
0
    public static void Write(OutputModel outputModel, DatabasePlan databasePlan, PartitionPlan partitionPlan)
    {
        var s = $@"
namespace {databasePlan.Namespace};

public class {partitionPlan.ClassName} : Cosmogenesis.Core.DbPartitionBase
{{
    protected virtual {databasePlan.Namespace}.{databasePlan.DbClassName} {databasePlan.DbClassName} {{ get; }} = default!;

    {PkClass(partitionPlan)}

    /// <summary>Mocking constructor</summary>
    protected {partitionPlan.ClassName}() {{ }}

    internal protected {partitionPlan.ClassName}(
        {new[] { ConstructorClassParameter(databasePlan), ConstructorKeyParameter(partitionPlan) }.Where(x => !string.IsNullOrEmpty(x)).JoinNonEmpty()})
        : base(
            db: {databasePlan.DbClassNameArgument},
            partitionKey: {partitionPlan.GetPkPlan.FullMethodName}({partitionPlan.GetPkPlan.DocumentToParametersMapping("pkData")}),
            serializer: {databasePlan.Namespace}.{databasePlan.SerializerClassName}.Instance)
    {{
        this.{databasePlan.DbClassName} = {databasePlan.DbClassNameArgument} ?? throw new System.ArgumentNullException(nameof({databasePlan.DbClassNameArgument}));
        {PkClassSetter(partitionPlan)}
    }}

    {databasePlan.Namespace}.{partitionPlan.QueryBuilderClassName}? queryBuilder;
    /// <summary>
    /// Methods to build queries for later execution.
    /// </summary>
    public virtual {databasePlan.Namespace}.{partitionPlan.QueryBuilderClassName} QueryBuilder => this.queryBuilder ??= new(
        {databasePlan.DbClassNameArgument}: this.{databasePlan.DbClassName},
        partitionKey: this.PartitionKey);

    {databasePlan.Namespace}.{partitionPlan.QueryClassName}? query;
    /// <summary>
    /// Methods to execute queries.
    /// </summary>
    public virtual {databasePlan.Namespace}.{partitionPlan.QueryClassName} Query => this.query ??= new(
        {databasePlan.DbClassNameArgument}: this.{databasePlan.DbClassName},
        {partitionPlan.QueryBuilderClassNameArgument}: this.QueryBuilder);

    /// <summary>
    /// A batch of operations to be executed atomically (or not at all) within a {partitionPlan.Name} in the {databasePlan.Name} database.
    /// </summary>
    public virtual {databasePlan.Namespace}.{partitionPlan.BatchClassName} CreateBatch() => new(
        transactionalBatch: this.CreateBatchForPartition(),
        partitionKey: this.PartitionKeyString,
        validateStateBeforeSave: this.{databasePlan.DbClassName}.ValidateStateBeforeSave,
        {partitionPlan.ClassNameArgument}: this);

    {databasePlan.Namespace}.{partitionPlan.ReadClassName}? read;
    /// <summary>
    /// Methods to read documents.
    /// </summary>
    public virtual {databasePlan.Namespace}.{partitionPlan.ReadClassName} Read => this.read ??= new(
        {databasePlan.DbClassNameArgument}: this.{databasePlan.DbClassName}, 
        partitionKey: this.PartitionKey);

    {databasePlan.Namespace}.{partitionPlan.ReadOrThrowClassName}? readOrThrow;
    /// <summary>
    /// Methods to read documents, or throw DbConflictException is they are not found.
    /// </summary>
    public virtual {databasePlan.Namespace}.{partitionPlan.ReadOrThrowClassName} ReadOrThrow => this.readOrThrow ??= new(
        {databasePlan.DbClassNameArgument}: this.{databasePlan.DbClassName}, 
        partitionKey: this.PartitionKey);

    {databasePlan.Namespace}.{partitionPlan.CreateClassName}? create;
    /// <summary>
    /// Methods to create documents.
    /// </summary>
    public virtual {databasePlan.Namespace}.{partitionPlan.CreateClassName} Create => this.create ??= new(this);

    {databasePlan.Namespace}.{partitionPlan.ReadOrCreateClassName}? readOrCreate;
    /// <summary>
    /// Methods to read documents, or create them if they did not yet exist.
    /// </summary>
    public virtual {databasePlan.Namespace}.{partitionPlan.ReadOrCreateClassName} ReadOrCreate => this.readOrCreate ??= new(this);

{ReadMany(databasePlan, partitionPlan)}
{CreateOrReplace(databasePlan, partitionPlan)}
{string.Concat(partitionPlan.Documents.Select(x => Create(partitionPlan, x)))}
{string.Concat(partitionPlan.Documents.Select(x => CreateOrReplace(partitionPlan, x)))}
{string.Concat(partitionPlan.Documents.Select(x => ReadOrCreate(partitionPlan, x)))}
{string.Concat(partitionPlan.Documents.Select(ReplaceIfMutable))}
{string.Concat(partitionPlan.Documents.Select(DeleteIfTransient))}
}}
";

        outputModel.Context.AddSource($"partition_{partitionPlan.ClassName}.cs", s);

        BatchWriter.Write(outputModel, databasePlan, partitionPlan);
        CreateWriter.Write(outputModel, databasePlan, partitionPlan);
        ReadOrCreateWriter.Write(outputModel, databasePlan, partitionPlan);
        CreateOrReplaceWriter.Write(outputModel, databasePlan, partitionPlan);
        ReadWriter.Write(outputModel, databasePlan, partitionPlan);
        ReadOrThrowWriter.Write(outputModel, databasePlan, partitionPlan);
        ReadManyWriter.Write(outputModel, databasePlan, partitionPlan);
        QueryBuilderWriter.Write(outputModel, databasePlan, partitionPlan);
        QueryWriter.Write(outputModel, databasePlan, partitionPlan);
    }
Esempio n. 19
0
    public static void Write(OutputModel outputModel, DatabasePlan databasePlan, PartitionPlan partitionPlan)
    {
        var s = $@"
namespace {databasePlan.Namespace};

public class {partitionPlan.BatchClassName} : Cosmogenesis.Core.DbBatchBase
{{
    protected virtual {databasePlan.Namespace}.{partitionPlan.ClassName} {partitionPlan.ClassName} {{ get; }} = default!;

    /// <summary>Mocking constructor</summary>
    protected {partitionPlan.BatchClassName}() {{ }}

    internal protected {partitionPlan.BatchClassName}(
        Microsoft.Azure.Cosmos.TransactionalBatch transactionalBatch,
        string partitionKey,
        bool validateStateBeforeSave,
        {databasePlan.Namespace}.{partitionPlan.ClassName} {partitionPlan.ClassNameArgument})
        : base(
            transactionalBatch: transactionalBatch,
            partitionKey: partitionKey,
            serializer: {databasePlan.Namespace}.{databasePlan.SerializerClassName}.Instance,
            validateStateBeforeSave: validateStateBeforeSave)
    {{
        this.{partitionPlan.ClassName} = {partitionPlan.ClassNameArgument} ?? throw new System.ArgumentNullException(nameof({partitionPlan.ClassNameArgument}));
    }}

    /// <summary>
    /// Queue a document for creation in the batch.
    /// Throws InvalidOperationException if the DbDoc does not belong in the partition.
    /// </summary>
    public virtual {databasePlan.Namespace}.{partitionPlan.BatchClassName} CheckAndCreate(Cosmogenesis.Core.DbDoc dbDoc) => dbDoc switch
    {{
{string.Concat(partitionPlan.Documents.Select(CheckedCreate))}
        null => throw new System.ArgumentNullException(nameof(dbDoc)),
        _ => throw new System.InvalidOperationException($""{{dbDoc.GetType().Name}} is not a type stored in this partition"")
    }};

    /// <summary>
    /// Tries to queue a document for creation in the batch.
    /// Returns true if queued, or false if the document does not belong in the partition.
    /// </summary>
    public virtual bool TryCheckAndCreate(Cosmogenesis.Core.DbDoc dbDoc) => dbDoc switch
    {{
{string.Concat(partitionPlan.Documents.Select(CheckedCreate))}
        null => throw new System.ArgumentNullException(nameof(dbDoc)),
        _ => ({databasePlan.Namespace}.{partitionPlan.BatchClassName}?)null
    }} != null;

    /// <summary>
    /// Queue a document for creation or replacement in the batch.
    /// Throws InvalidOperationException if the DbDoc does not belong in the partition or is not mutable.
    /// </summary>
    public virtual {databasePlan.Namespace}.{partitionPlan.BatchClassName} CheckAndCreateOrReplace(Cosmogenesis.Core.DbDoc dbDoc) => dbDoc switch
    {{
{string.Concat(partitionPlan.Documents.Where(x => x.IsMutable || x.IsTransient).Select(CheckedCreateOrReplace))}
        null => throw new System.ArgumentNullException(nameof(dbDoc)),
        _ => throw new System.InvalidOperationException($""{{dbDoc.GetType().Name}} is not a mutable type in this partition"")
    }};

    /// <summary>
    /// Tries to queue a document for creation or replacement in the batch.
    /// Returns true if queued, or false if the document does not belong in the partition or is not mutable.
    /// </summary>
    public virtual bool TryCheckAndCreateOrReplace(Cosmogenesis.Core.DbDoc dbDoc) => dbDoc switch
    {{
{string.Concat(partitionPlan.Documents.Where(x => x.IsMutable || x.IsTransient).Select(CheckedCreateOrReplace))}
        null => throw new System.ArgumentNullException(nameof(dbDoc)),
        _ => ({databasePlan.Namespace}.{partitionPlan.BatchClassName}?)null
    }} != null;

    /// <summary>
    /// Queue a document for replacement in the batch.
    /// Throws InvalidOperationException if the DbDoc does not belong in the partition or is not mutable.
    /// </summary>
    public virtual {databasePlan.Namespace}.{partitionPlan.BatchClassName} CheckAndReplace(Cosmogenesis.Core.DbDoc dbDoc) => dbDoc switch
    {{
        {string.Concat(partitionPlan.Documents.Where(x => x.IsMutable).Select(CheckedReplace))}
        null => throw new System.ArgumentNullException(nameof(dbDoc)),
        _ => throw new System.InvalidOperationException($""{{dbDoc.GetType().Name}} is not a mutable type in this partition"")
    }};

    /// <summary>
    /// Tries to queue a document for replacement in the batch.
    /// Returns true if queued, or false if the document does not belong in the partition or is not mutable.
    /// </summary>
    public virtual bool TryCheckAndReplace(Cosmogenesis.Core.DbDoc dbDoc) => dbDoc switch
    {{
        {string.Concat(partitionPlan.Documents.Where(x => x.IsMutable).Select(CheckedReplace))}
        null => throw new System.ArgumentNullException(nameof(dbDoc)),
        _ => ({databasePlan.Namespace}.{partitionPlan.BatchClassName}?)null
    }} != null;

    /// <summary>
    /// Queue a document for deletion in the batch.
    /// Throws InvalidOperationException if the DbDoc does not belong in the partition or is not transient.
    /// </summary>
    public virtual {databasePlan.Namespace}.{partitionPlan.BatchClassName} CheckAndDelete(Cosmogenesis.Core.DbDoc dbDoc) => dbDoc switch
    {{
        {string.Concat(partitionPlan.Documents.Where(x => x.IsTransient).Select(CheckedDelete))}
        null => throw new System.ArgumentNullException(nameof(dbDoc)),
        _ => throw new System.InvalidOperationException($""{{dbDoc.GetType().Name}} is not a transient type in this partition"")
    }};

    /// <summary>
    /// Tries to queue a document for deletion in the batch.
    /// Returns true if queued, or false if the document does not belong in the partition or is not transient.
    /// </summary>
    public virtual bool TryCheckAndDelete(Cosmogenesis.Core.DbDoc dbDoc) => dbDoc switch
    {{
        {string.Concat(partitionPlan.Documents.Where(x => x.IsTransient).Select(CheckedDelete))}
        null => throw new System.ArgumentNullException(nameof(dbDoc)),
        _ => ({databasePlan.Namespace}.{partitionPlan.BatchClassName}?)null
    }} != null;

{string.Concat(partitionPlan.Documents.Select(x => Create(databasePlan, partitionPlan, x)))}
{string.Concat(partitionPlan.Documents.Select(x => CreateOrReplace(databasePlan, partitionPlan, x)))}
{string.Concat(partitionPlan.Documents.Select(x => Replace(databasePlan, partitionPlan, x)))}
{string.Concat(partitionPlan.Documents.Select(x => Delete(databasePlan, partitionPlan, x)))}
}}
";

        outputModel.Context.AddSource($"partition_{partitionPlan.BatchClassName}.cs", s);
    }
Esempio n. 20
0
 private string SerializeOutput(OutputModel <T> outputModel)
 {
     return(JsonConvert.SerializeObject(outputModel));
 }
Esempio n. 21
0
        public BillViewModel()
        {
            LoadOutputData();
            loadUserCurrentLogin();

            LoadEditCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { LoadDialogAccountEdit(); });

            DeleteDetailCommand = new RelayCommand <object>((p) =>
            {
                if (SelectedItemOutputDetail == null)
                {
                    return(false);
                }
                return(true);
            }, (p) =>
            {
                DeleteNotificationMessage msg = new DeleteNotificationMessage();
                Message = "Xóa Thông Tin Có Thể Dẫn Đến Sai Lệch Dữ Liệu! Bạn Chắc Chắn Chứ?";
                DialogHost.Show(msg, "BillDialog");
            });

            DeleteConfirmCommand = new RelayCommand <object>((p) =>
            {
                return(true);
            }, (p) =>
            {
                OutPutDetailTable detailItem = DataProvider.Ins.Entities.OutPutDetailTable.Where(x => x.ID == SelectedItemOutputDetail.Output.ID).FirstOrDefault();
                DataProvider.Ins.Entities.OutPutDetailTable.Remove(detailItem);
                DataProvider.Ins.Entities.SaveChanges();

                ListOutputDetail = new List <OutputDetailModel>();
                var List         = DataProvider.Ins.Entities.OutPutDetailTable.Where(x => x.ID_Output == SelectedItemOutput.Output.ID);
                foreach (var item in List)
                {
                    OutputDetailModel detail = new OutputDetailModel();
                    ProductTable product     = new ProductTable();
                    product        = DataProvider.Ins.Entities.ProductTable.Where(x => x.ID == item.ID_Product).FirstOrDefault();
                    detail.Output  = item;
                    detail.Product = product;
                    ListOutputDetail.Add(detail);
                }
                DialogHost.CloseDialogCommand.Execute(null, null);

                SelectedItemOutputDetail = null;

                IsActiveSnackBar          = true;
                Message                   = "Xóa Chi Tiết Thành Công!";
                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Interval            = 5000;
                timer.Enabled             = true;
                timer.Elapsed            += ShowSnackBar;
                timer.Start();
            });

            DeleteOutputCommand = new RelayCommand <object>((p) =>
            {
                return(true);
            }, (p) =>
            {
                var List = DataProvider.Ins.Entities.OutPutDetailTable.Where(x => x.ID_Output == SelectedItemOutput.Output.ID);
                if (List.Count() != 0)
                {
                    ErrorNotificationMessage msg = new ErrorNotificationMessage();
                    Message = "Phiếu Nhập Này Đang Có Chi Tiết! Bạn Vui Lòng Xóa Bỏ Các Thông Tin Liên Quan!";
                    DialogHost.Show(msg, "BillDialog");
                    return;
                }

                DataProvider.Ins.Entities.OutputTable.Remove(SelectedItemOutput.Output);
                DataProvider.Ins.Entities.SaveChanges();

                LoadOutputData();
                DialogHost.CloseDialogCommand.Execute(null, null);

                SelectedItemOutput = null;

                IsActiveSnackBar          = true;
                Message                   = "Xóa Phiếu Nhập Thành Công!";
                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Interval            = 5000;
                timer.Enabled             = true;
                timer.Elapsed            += ShowSnackBar;
                timer.Start();
            });

            SearchCommand = new RelayCommand <object>((p) =>
            {
                return(true);
            },
                                                      (p) =>
            {
                if (SearchTermOutput == null)
                {
                    return;
                }


                var ListInput             = DataProvider.Ins.Entities.OutputTable;
                List <OutputModel> Result = new List <OutputModel>();
                foreach (var item in ListInput)
                {
                    OutputModel output = new OutputModel();
                    output.Output      = item;
                    output.User        = DataProvider.Ins.Entities.UserTable.Where(x => x.ID == item.ID_User).FirstOrDefault();
                    output.Customer    = DataProvider.Ins.Entities.CustomerTable.Where(x => x.ID == item.ID_Customer).FirstOrDefault();
                    Result.Add(output);
                }

                ListOutput = new List <OutputModel>(Result.Where(
                                                        x => x.Output.DateOutput.ToString().ToLower().Contains(SearchTermOutput) ||
                                                        x.User.DisplayName.ToLower().Contains(SearchTermOutput) || x.Customer.FullName.ToLower().Contains(SearchTermOutput)
                                                        ));
            });
        }
 public HTMLSelectOrgItemsViewComponent()
 {
     _model = new OutputModel();
 }
Esempio n. 23
0
 public bool GetCareer(string personaId, out OutputModel <CareerViewModel> outputModel)
 {
     return(GetCareer(new RequestParams {
         PersonaId = personaId
     }, out outputModel));
 }
Esempio n. 24
0
 public bool GetServerDetails(string game, string gameId, out OutputModel <ServerDetailsViewModel> outputModel)
 {
     return(GetServerDetails(new RequestParams {
         Game = game, GameId = gameId
     }, out outputModel));
 }
Esempio n. 25
0
    static void AddPartitionDefinition(OutputModel outputModel, DatabasePlan databasePlan, MethodModel methodModel, string name)
    {
        if (databasePlan.PartitionPlansByName.TryGetValue(name, out var partitionPlan))
        {
            if (!SymbolEqualityComparer.Default.Equals(partitionPlan.GetPkModel.MethodSymbol, methodModel.MethodSymbol))
            {
                outputModel.Report(Diagnostics.Errors.PartitionAlreadyDefined, methodModel.MethodSymbol);
            }
        }
        else
        {
            partitionPlan = new PartitionPlan
            {
                Name                        = name,
                PluralName                  = name.Pluralize(),
                ClassName                   = name.WithSuffix(Suffixes.Partition),
                BatchHandlersClassName      = name.WithSuffix(Suffixes.BatchHandlers),
                CreateOrReplaceClassName    = name.WithSuffix(Suffixes.CreateOrReplace),
                ReadClassName               = name.WithSuffix(Suffixes.Read),
                ReadOrThrowClassName        = name.WithSuffix(Suffixes.ReadOrThrow),
                ReadManyClassName           = name.WithSuffix(Suffixes.ReadMany),
                ReadUnionsClassName         = name.WithSuffix(Suffixes.ReadUnions),
                ReadOrThrowUnionsClassName  = name.WithSuffix(Suffixes.ReadOrThrowUnions),
                ReadManyUnionsClassName     = name.WithSuffix(Suffixes.ReadManyUnions),
                QueryBuilderClassName       = name.WithSuffix(Suffixes.QueryBuilder),
                QueryBuilderUnionsClassName = name.WithSuffix(Suffixes.QueryBuilderUnions),
                QueryClassName              = name.WithSuffix(Suffixes.Query),
                QueryUnionsClassName        = name.WithSuffix(Suffixes.QueryUnions),
                ReadOrCreateClassName       = name.WithSuffix(Suffixes.ReadOrCreate),
                CreateClassName             = name.WithSuffix(Suffixes.Create),
                BatchClassName              = name.WithSuffix(Suffixes.Batch),
                GetPkModel                  = methodModel
            };
            partitionPlan.BatchHandlersClassNameArgument = partitionPlan.BatchHandlersClassName.ToArgumentName();
            partitionPlan.ClassNameArgument             = partitionPlan.ClassName.ToArgumentName();
            databasePlan.PartitionPlansByName[name]     = partitionPlan;
            partitionPlan.QueryBuilderClassNameArgument = partitionPlan.QueryBuilderClassName.ToArgumentName();

            outputModel.ValidateNames(
                methodModel.MethodSymbol,
                partitionPlan.Name,
                partitionPlan.PluralName,
                partitionPlan.ClassName,
                partitionPlan.BatchHandlersClassName,
                partitionPlan.CreateOrReplaceClassName,
                partitionPlan.ReadClassName,
                partitionPlan.ReadOrThrowClassName,
                partitionPlan.ReadManyClassName,
                partitionPlan.QueryBuilderClassName,
                partitionPlan.QueryClassName,
                partitionPlan.ReadOrCreateClassName,
                partitionPlan.CreateClassName,
                partitionPlan.BatchClassName,
                partitionPlan.QueryBuilderUnionsClassName,
                partitionPlan.QueryUnionsClassName,
                partitionPlan.ReadManyUnionsClassName,
                partitionPlan.ReadOrThrowUnionsClassName,
                partitionPlan.ReadUnionsClassName);

            outputModel.ValidateIdentifiers(
                methodModel.MethodSymbol,
                partitionPlan.ClassNameArgument,
                partitionPlan.BatchHandlersClassNameArgument,
                partitionPlan.QueryBuilderClassNameArgument);
        }
    }
Esempio n. 26
0
 public PhoneManagerAppParamHolder(CookieHolder cookieHolder, string repositoryTestPhoneManagerData, NameValueCollection queryStringCollection, string referrerString, OutputModel sessionModel, string umbracoCurrentPageId)
 {
     CookieProvider      = CookieProvider(cookieHolder).Object;
     RepositoryProvider  = Repository(repositoryTestPhoneManagerData);
     QueryStringProvider = new QueryStringProvider(QueryStringImplementation(queryStringCollection).Object);
     ReferrerProvider    = new ReferrerProvider(ReferrerImplementation(referrerString).Object);
     SessionProvider     = SessionProvider(sessionModel).Object;
     UmbracoProvider     = UmbracoProvider(umbracoCurrentPageId).Object;
 }
Esempio n. 27
0
        public async Task <IActionResult> CallAPI()
        {
            // Retrieve an access token for the WebAPI
            string accessToken = await GetAPIAccessToken();

            if (string.IsNullOrEmpty(accessToken))
            {
                // If an empty access token is returned, acquistion of the access token for the APIM
                // gateway via Client Credentials failed, redirect to the home page.
                return(RedirectToAction("Index"));
            }
            else
            {
                InputModel model = new InputModel();
                model.IntegerInput = new int[] { 23, 66 };
                model.StringInput  = new string[] { "Add", "Integer" };

                HttpClient httpClient = new HttpClient();
                using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, _configuration.GetValue <string>("AzureADB2C:ApiUrl")))
                {
                    // Set the authorization header
                    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
                    // Set the subscription key
                    request.Headers.Add("Ocp-Apim-Subscription-Key", _configuration.GetValue <string>("APIMSubscriptionKey"));
                    string content = JsonConvert.SerializeObject(model);
                    request.Content = new StringContent(content, Encoding.UTF8, "application/json");

                    // Send the request to APIM endpoint
                    using (HttpResponseMessage response = await httpClient.SendAsync(request))
                    {
                        string error = await response.Content.ReadAsStringAsync();

                        // Check the result for error
                        if (!response.IsSuccessStatusCode)
                        {
                            // Throw server busy error message
                            if (response.StatusCode == (HttpStatusCode)429)
                            {
                                // TBD: Add you error handling here
                            }

                            throw new Exception(error);
                        }

                        // Return the response body, usually in JSON format
                        OutputModel outputModel = JsonConvert.DeserializeObject <OutputModel>(await response.Content.ReadAsStringAsync());
                        ViewBag.Operation = model.StringInput[0];
                        if (model.StringInput[1] == "Integer")
                        {
                            ViewBag.Calc1Input1 = model.IntegerInput[0];
                            ViewBag.Calc1Input2 = model.IntegerInput[1];
                            ViewBag.Calc1Result = outputModel.IntegerOutput[0];
                        }
                        else
                        {
                            ViewBag.Calc1Input1 = model.DecimalInput[0];
                            ViewBag.Calc1Input2 = model.DecimalInput[1];
                            ViewBag.Calc1Result = outputModel.DecimalOutput[0];
                        }
                    }
                }
            }

            return(View());
        }
Esempio n. 28
0
        public ActionResult List()
        {
            var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
            var client = new Kubernetes(config);

            var list = client.ListNamespacedService("minecraft");

            if (list?.Items?.Count == 0)
            {
                return(NotFound());
            }

            var output = new List <OutputModel>();

            foreach (var item in list.Items)
            {
                var o = new OutputModel();

                o.Nome = item.Metadata.Name;

                if (item.Status?.LoadBalancer?.Ingress?.Count > 0)
                {
                    o.Enderecos = new List <EnderecoModel>();

                    foreach (var i in item.Status.LoadBalancer.Ingress)
                    {
                        using (var wc = new WebClient())
                        {
                            var     status = wc.DownloadString($"https://mcapi.us/server/status?ip={i.Ip}");
                            dynamic sta    = JObject.Parse(status);

                            var a = sta.status;

                            o.Enderecos.Add(new EnderecoModel()
                            {
                                IP          = i.Ip,
                                Nome        = i.Hostname,
                                MaxCapacity = sta.players.max,
                                Online      = sta.players.now,
                            });
                        }
                    }
                }

                foreach (var e in o.Enderecos)
                {
                    if (item.Spec?.Ports?.Count > 0)
                    {
                        foreach (var p in item.Spec.Ports)
                        {
                            e.Ports += $"{p.Port},";
                        }

                        e.Ports = e.Ports.Substring(0, e.Ports.Length - 2);
                    }
                }

                output.Add(o);
            }

            return(new JsonResult(output));
        }
        protected override OutputModel <ManageDeckSlotType> ProcessIntent()
        {
            string dialogActionType = Constants.DIALOG_ACTION_TYPE_ELICIT;
            string fulfillmentState = null;
            string intentName       = InputModel.CurrentIntent.Name;
            var    slots            = InputModel.CurrentIntent.Slots;
            var    errors           = InputModel.CurrentIntent.Slots.Validate();
            string slotToElicit     = InputModel.CurrentIntent.Slots.GetSlotToElicit();
            string responseMessage  = String.Empty;
            string manageType       = InputModel.CurrentIntent.Slots.ManageType.ToLower();

            if (slotToElicit == nameof(ManageDeckSlotType.ManageType))
            {
                var error = errors.FirstOrDefault(rr => rr.PropertyName == nameof(ManageDeckSlotType.ManageType));

                if (error != null)
                {
                    responseMessage = "Would you like to add a new, modify an existing, or delete a flash card deck?";
                }
                else
                {
                    responseMessage = String.Format(Constants.ERROR_MESSAGE_INVALID_VALUE, "Manage Type is invalid");
                    InputModel.CurrentIntent.Slots.ManageType = null;
                }
            }
            else if (slotToElicit == nameof(ManageDeckSlotType.DeckName))
            {
                responseMessage = String.Format("What is the name of the flash card deck you'd like to {0}?", manageType);
                var allDecks = Dal.GetAllDecks(InputModel.UserID);
                if (allDecks != null && allDecks.Any())
                {
                    responseMessage = String.Format("{0} {1}", responseMessage, DeckUtilitites.CreateDeckInformationMessage(allDecks));
                }
            }
            else if (slotToElicit == nameof(ManageDeckSlotType.Front))
            {
                if (Dal.DeckExits(InputModel.UserID, slots.DeckName))
                {
                    responseMessage = "Enter the front of the card";
                }
                else
                {
                    responseMessage  = String.Format("You don't have a flash card deck named {0}!", slots.DeckName);
                    slotToElicit     = null;
                    dialogActionType = Constants.DIALOG_ACTION_TYPE_CLOSE;
                    fulfillmentState = Constants.FULLFILLMENT_STATE_FULFILLED;
                    intentName       = null;
                    slots            = null;
                }
            }
            else if (slotToElicit == nameof(ManageDeckSlotType.Back))
            {
                responseMessage = "Enter the back of the card";
            }
            else if (slotToElicit == nameof(ManageDeckSlotType.Confirm))
            {
                bool fulFill = false;
                if (manageType == Constants.ManageTypes.Add.ToString().ToLower())
                {
                    if (!Dal.DeckExits(InputModel.UserID, slots.DeckName))
                    {
                        responseMessage = String.Format("Are you sure you want to add {0} as a new flash card deck?", InputModel.CurrentIntent.Slots.DeckName);
                    }
                    else
                    {
                        fulFill         = true;
                        responseMessage = String.Format("You already have a deck named {0}!", slots.DeckName);
                    }
                }
                else if (manageType == Constants.ManageTypes.Delete.ToString().ToLower())
                {
                    if (Dal.DeckExits(InputModel.UserID, slots.DeckName))
                    {
                        responseMessage = String.Format("Are you sure you want to delete the flash card deck named {0}", InputModel.CurrentIntent.Slots.DeckName);
                    }
                    else
                    {
                        fulFill         = true;
                        responseMessage = String.Format("You don't have a deck named {0}!", slots.DeckName);
                    }
                }
                else if (manageType == Constants.ManageTypes.Modify.ToString().ToLower())
                {
                    Dal.AddCardToDeck(InputModel.UserID, slots.DeckName, slots.Front, slots.Back);
                    responseMessage = "Would you like to add another?";
                }
                if (fulFill)
                {
                    slotToElicit     = null;
                    dialogActionType = Constants.DIALOG_ACTION_TYPE_CLOSE;
                    fulfillmentState = Constants.FULLFILLMENT_STATE_FULFILLED;
                    intentName       = null;
                    slots            = null;
                }
            }
            else if (slotToElicit == string.Empty)
            {
                if (InputModel.CurrentIntent.Slots.Confirm.ToLower() == "yes")
                {
                    string successType = String.Empty;
                    if (manageType == Constants.ManageTypes.Modify.ToString().ToLower())
                    {
                        slots.Front     = null;
                        slots.Back      = null;
                        slots.Confirm   = null;
                        slotToElicit    = slots.GetSlotToElicit();
                        responseMessage = "Enter the front of the card";
                    }
                    else
                    {
                        if (manageType == Constants.ManageTypes.Add.ToString().ToLower())
                        {
                            manageType = "added";
                            Dal.AddNewDeck(InputModel.UserID, slots.DeckName);
                            responseMessage = String.Format(Constants.MESSAGE_RESPONSE_UPDATE_SUCCESS, manageType);
                        }
                        else if (manageType == Constants.ManageTypes.Delete.ToString().ToLower())
                        {
                            manageType      = "deleted";
                            responseMessage = String.Format(Constants.MESSAGE_RESPONSE_UPDATE_SUCCESS, manageType);
                            Dal.DeleteDeck(InputModel.UserID, slots.DeckName);
                        }
                        slotToElicit     = null;
                        dialogActionType = Constants.DIALOG_ACTION_TYPE_CLOSE;
                        fulfillmentState = Constants.FULLFILLMENT_STATE_FULFILLED;
                        intentName       = null;
                        slots            = null;
                    }
                }
                else
                {
                    responseMessage  = "OK";
                    slotToElicit     = null;
                    dialogActionType = Constants.DIALOG_ACTION_TYPE_CLOSE;
                    fulfillmentState = Constants.FULLFILLMENT_STATE_FULFILLED;
                    intentName       = null;
                    slots            = null;
                }
            }

            var outputModel = new OutputModel <ManageDeckSlotType>();

            outputModel.dialogAction.type                = dialogActionType;
            outputModel.dialogAction.fulfillmentState    = fulfillmentState;
            outputModel.dialogAction.slots               = slots;
            outputModel.dialogAction.message.content     = responseMessage;
            outputModel.dialogAction.message.contentType = Constants.RESPONSE_CONTENT_TYPE;
            outputModel.dialogAction.slotToElicit        = slotToElicit;
            outputModel.dialogAction.intentName          = intentName;
            return(outputModel);
        }
Esempio n. 30
0
 public bool GetWeaponStats(string game, string personaId, out OutputModel <List <WeaponStatCategory> > outputModel)
 {
     return(GetWeaponStats(new RequestParams {
         Game = game, PersonaId = personaId
     }, out outputModel));
 }