Esempio n. 1
0
        public async Task <string> PutAsync([FromBody] MemberHolidayEntity PEntity)
        {
            ExcuteResult actResult = new ExcuteResult();

            if (await _DataRepository.UpdateAsync(PEntity).ConfigureAwait(false) > 0)
            {
                actResult.SetValues(0, "更新成功");
            }
            else
            {
                actResult.SetValues(1, "更新失败");
            }
            return(JsonConvert.SerializeObject(actResult));
        }
Esempio n. 2
0
        public async Task <string> DeleteAsync(string Id)
        {
            ExcuteResult actResult = new ExcuteResult();

            if (await _DataRepository.DeleteAsync(Id).ConfigureAwait(false) > 0)
            {
                actResult.SetValues(0, "删除成功");
            }
            else
            {
                actResult.SetValues(1, "删除失败");
            }
            return(JsonConvert.SerializeObject(actResult));
        }
Esempio n. 3
0
        public async Task <string> PostAsync([FromBody] MemberHolidayEntity PEntity)
        {
            ExcuteResult actResult = new ExcuteResult();

            if (await _DataRepository.AddAsync(PEntity).ConfigureAwait(false) > 0)
            {
                actResult.SetValues(p_state: 0, p_msg: "保存成功", p_tag: PEntity?.Id);
            }
            else
            {
                actResult.SetValues(1, "保存失败");
            }
            return(JsonConvert.SerializeObject(actResult));
        }
Esempio n. 4
0
        public async Task <ActionResult <string> > AddEntity([FromBody] MemberInfoEntity PEntity)
        {
            ExcuteResult actResult = new ExcuteResult();

            if (await _MemberRepository.AddAsync(PEntity).ConfigureAwait(false) > 0)
            {
                actResult.SetValues(0, "保存成功");
            }
            else
            {
                actResult.SetValues(1, "保存失败");
            }
            return(JsonConvert.SerializeObject(actResult));
        }
Esempio n. 5
0
        public async Task <ActionResult <string> > PostAsync([FromBody] MemberPayItemEntity PEntity)
        {
            ExcuteResult actResult = new ExcuteResult();

            if (await _PayRepository.AddAsync(PEntity).ConfigureAwait(false) > 0)
            {
                actResult.SetValues(p_state: 0, p_msg: "保存成功");
            }
            else
            {
                actResult.SetValues(1, "保存失败");
            }
            return(JsonConvert.SerializeObject(actResult));
        }
        public async Task <string> PutAsync([FromBody] PlanFileEntity PEntity)
        {
            ExcuteResult actResult = new ExcuteResult();

            if (await _FileRepository.UpdateAsync(PEntity).ConfigureAwait(false) > 0)
            {
                actResult.SetValues(p_state: 0, p_msg: "文件信息更新成功", p_tag: PEntity?.Id);
            }
            else
            {
                actResult.SetValues(1, "文件信息更新失败!");
            }
            return(JsonConvert.SerializeObject(actResult));
        }
        public async Task <string> Delete(string FileId)
        {
            ExcuteResult actResult = new ExcuteResult();

            if (await _FileRepository.DeleteByIdAsync(_FileBaseDir, FileId).ConfigureAwait(false) > 0)
            {
                actResult.SetValues(0, "删除成功!");
            }
            else
            {
                actResult.SetValues(1, "删除失败!");
            }
            return(JsonConvert.SerializeObject(actResult));
        }
Esempio n. 8
0
        public async Task <string> DeleteEntity(string Id)
        {
            ExcuteResult actResult = new ExcuteResult();

            if (await _MemberRepository.DeleteAsync(Id).ConfigureAwait(false) > 0)
            {
                await _FileRepository.DeleteByOwnerIdAsync(_FileBaseDir, Id).ConfigureAwait(false);

                actResult.SetValues(0, "删除成功");
            }
            else
            {
                actResult.SetValues(1, "删除失败");
            }
            return(JsonConvert.SerializeObject(actResult));
        }
Esempio n. 9
0
        public async Task <ActionResult <string> > PutAsync([FromBody] PlanEntity PEntity)
        {
            ExcuteResult actResult = new ExcuteResult();

            if (PEntity != null && !PEntity.CurrectState.Equals(PlanStatus.WaitBegin, StringComparison.Ordinal))
            {
                PEntity.FinishDate = DateTime.Now;
            }
            if (await _PlanRepository.UpdateAsync(PEntity).ConfigureAwait(false) > 0)
            {
                actResult.SetValues(0, "更新成功");
            }
            else
            {
                actResult.SetValues(1, "更新失败");
            }
            return(JsonConvert.SerializeObject(actResult));
        }
        public async Task <string> PostUpLoadFileAsync([FromForm] PlanFileEntity PFile)
        {
            ExcuteResult actResult = new ExcuteResult();

            if (Request.Form.Files.Count > 0 && PFile != null)
            {
                try
                {
                    string FileId = AppCodes.AppStaticClass.GetIdOfDateTime();
                    if (!System.IO.Directory.Exists(_FileBaseDir))
                    {
                        System.IO.Directory.CreateDirectory(_FileBaseDir);
                    }
                    string FileName = Path.Combine(_FileBaseDir, $"{FileId}{PFile.ExtendName}");// _configuration["StaticFileDir"] + $"\\WorkFiles\\{pfile.Id}{pfile.ExtendName}";
                    using (FileStream fs = System.IO.File.Create(FileName))
                    {
                        await Request.Form.Files[0].CopyToAsync(fs).ConfigureAwait(false);
                        fs.Flush();
                    }
                    if (System.IO.File.Exists(FileName))
                    {
                        //文件写入成功后,再保存文件信息到数据表
                        PFile.UpDateTime = DateTime.Now;
                        if (await _FileRepository.AddAsync(PFile, FileId).ConfigureAwait(false) > 0)
                        {
                            actResult.SetValues(0, "上传成功", p_tag: FileId);
                        }
                        else
                        {
                            actResult.SetValues(-3, "文件保存到服务器数据库时出错。");
                        }
                    }
                    else
                    {
                        actResult.SetValues(-1, "文件保存到服务器磁盘时出错。");
                    }
                }
                catch (System.Exception err)
                {
                    actResult.SetValues(1, err.Message);
                }
            }
            return(JsonConvert.SerializeObject(actResult));
        }