Exemplo n.º 1
0
        public async Task <ActionResult> CreateTask(Automation_Tasks task)
        {
            var newItem = database.Automation_Tasks.Add(task);
            await database.SaveChangesAsync();

            return(new ContentResult
            {
                Content = JsonConvert.SerializeObject(newItem),
                ContentType = "application/json",
                ContentEncoding = Encoding.UTF8
            });
        }
Exemplo n.º 2
0
        public async Task <ActionResult> UpdateTask(Automation_Tasks task)
        {
            var newItem = database.Automation_Tasks.Find(task.ID);

            database.Entry(task).State = EntityState.Modified;
            await database.SaveChangesAsync();

            return(new ContentResult
            {
                Content = JsonConvert.SerializeObject(newItem),
                ContentType = "application/json",
                ContentEncoding = Encoding.UTF8
            });
        }
        public async Task <ActionResult> Create_ReturenedProduct(string totalItem, string description)
        {
            if (ModelState.IsValid)
            {
                //ایجاد آیتم در جنریک
                var GenericItem = database.Automation_Generic.Add(
                    new Automation_Generic
                {
                    ID    = Guid.NewGuid(),
                    Title = "BaniChav_ReturnedProducts"
                });

                //ایجاد آیتم در ریترند پروداکت
                var ReturnedItem = database.BaniChav_ReturnedProducts.Add(
                    new BaniChav_ReturnedProducts
                {
                    ID               = Guid.NewGuid(),
                    genericId        = GenericItem.ID,
                    Title            = "",
                    Description      = description,
                    BaniChav_TotalID = new Guid(totalItem)
                });
                //ایجاد آیتم در تسک لیست
                var taskId = Guid.NewGuid();
                List <Automation_Tasks> taskList = new List <Automation_Tasks>();
                Automation_Tasks        task1    = new Automation_Tasks
                {
                    ID            = taskId,
                    Title         = "01 - رویه کالای مرجوعی",
                    Filter1       = "مرجوعی",
                    Filter2       = "مرجوعی",
                    Filter3       = "مرجوعی",
                    genericId     = GenericItem.ID,
                    IsActive      = true,
                    IsDone        = false,
                    Responsible   = new Guid("8a27ed23-32d8-4139-b959-6441c49adaad"),
                    TaskOrder     = 1,
                    ApproveHtml   = "<button class=btnApprove id='btnApprove_" + taskId + "'><span class='glyphicon glyphicon-ok' area-hidden=true></span></button>",
                    RejectHtml    = "<button  class=btnReject id='btnReject_" + taskId + "'><span class='glyphicon glyphicon-remove' area-hidden=true></span></button>",
                    ApproveScript =
                        "$(document).on('click','#btnApprove_" + taskId + "',function(e){" +
                        "e.preventDefault();" +
                        "var txtDescription=$(this).closest('.panel').find('.txtDescription').val();" +
                        "if(txtDescription != '')" +
                        "{" +
                        "ASQ()" +
                        ".all" +
                        "(" + // start all
                        "DoneTask('" + taskId + "')," +
                        "ActiveTask('" + GenericItem.ID + "',2)" +
                        ")" + // end all
                        //".then" +
                        //"(" +
                        //"function(done)" +
                        //"{" +
                        //"$.ajax({url:'/BaniChav/Select_ReturenedProduct_Async',data:{genericId:'" + GenericItem.ID + "'}})" +
                        //".success(function(result){" +
                        //"done(result);" +
                        //"})" +//end success ajax
                        //"}"+//end function(done)
                        //")" +//end then
                        ".then" +
                        "(" +
                        "function(done)" +
                        "{" +
                        "$.ajax({url:'/BaniChav/UpdateDescription_ReturenedProduct_Async',data:{genericId:'" + GenericItem.ID + "',Description:txtDescription}})" +
                        ".success(function(result){" +
                        "done(result);" +
                        "})" + //end success
                        "}" +  //end function(done)
                        ")" +  //end then
                        ".then" +
                        "(" +
                        "function(done)" +
                        "{" +
                        "Notify('success','ثبت با موفقیت انجام شد',2000,2);" +
                        "HidePanel('" + taskId + "')" +
                        "}" + //end function(done)
                        ")" + //end then
                        "}" + //end If
                        "else" +
                        "{" +
                        "Notify('error','لطفا توضیحات را وارد نمایید',2000,2);" +
                        "}" +
                        "});"//end click
                    ,
                    Html =
                        "<table class=table>" +
                        "<tr style=background-color:#D9EDF7;color:#3A87AD;>" +
                        "<th>توضیحات</th>" +
                        "</tr>" +
                        "<tr>" +
                        "<td><input type=text class='txtDescription' /></td>" +
                        "</tr>" +
                        "<table>",
                    RejectScript =
                        "$(document).on('click', '#btnReject_" + taskId + "', function(e){" +
                        "e.preventDefault();" +
                        "if(confirm('مطمئن هستید برای لغو رویه'))" +
                        "{" +
                        "RejectTask('" + taskId + "');" +
                        "Notify('error','رویه با موفقیت لغو گردید',2000,2);" +
                        "HidePanel('" + taskId + "');" +
                        "}" +
                        "});"//end  click
                };
                taskList.Add(task1);



                database.Automation_Tasks.AddRange(taskList);
                await database.SaveChangesAsync();

                return(new ContentResult
                {
                    Content = JsonConvert.SerializeObject(""),
                    ContentType = "application/json",
                    ContentEncoding = Encoding.UTF8,
                });
            }
            else
            {
                return(new ContentResult
                {
                    Content = JsonConvert.SerializeObject(false),
                    ContentType = "application/json",
                    ContentEncoding = Encoding.UTF8
                });
            }
        }