示例#1
0
        /// <summary>
        /// 获取一个任务
        /// </summary>
        public virtual OrderInfo Get()
        {
            if (this.TaskInfo.IsDisabled)
            {
                throw new ErrorMsgException("该任务已经被删除");
            }
            var now = DateTime.Now;

            if (now < this.TaskInfo.StartTime)
            {
                throw new ErrorMsgException("该任务还没有开始");
            }
            if (now > this.TaskInfo.EndTime)
            {
                throw new ErrorMsgException("该任务已经过期");
            }

            var getTask = dataAccess.First <OrderInfo>(a => (a.IPAddress == this.ClientInfo.IpAddress || a.IDFA == this.ClientInfo.IDFA) && a.TaskInfoId == this.TaskInfo.Id && a.Status != Data.Enums.OrderStatus.未完成);

            if (getTask != null)
            {
                if (getTask.IPAddress == this.ClientInfo.IpAddress)
                {
                    throw new ErrorMsgException("您当前IP已经领取过该任务了");
                }
                if (getTask.IDFA == this.ClientInfo.IDFA)
                {
                    throw new ErrorMsgException("您当前手机已经领取过该任务了");
                }
            }

            var doingTask = dataAccess.First <OrderInfo>(a => (a.IPAddress == this.ClientInfo.IpAddress || a.IDFA == this.ClientInfo.IDFA) && a.Status != Data.Enums.OrderStatus.已完成 && a.Status != Data.Enums.OrderStatus.未完成);

            if (doingTask != null)
            {
                if (doingTask.IPAddress == this.ClientInfo.IpAddress)
                {
                    throw new ErrorMsgException("您当前IP同时只能进行一个任务");
                }
                if (doingTask.IDFA == this.ClientInfo.IDFA)
                {
                    throw new ErrorMsgException("您当前手机同时只能进行一个任务");
                }
            }
            //领取
            //lock (obj)
            //{

            //if (dataAccess.DbContext.Database.ExecuteSqlCommand("update TaskInfoes set Number = Number - 1 where Id = @p0 and Number > 0", this.TaskInfo.Id) != 1)
            //    throw new ErrorMsgException("任务已经被领取完了");

            //this.TaskInfo.Number = this.TaskInfo.Number - 1;
            //if (this.TaskInfo.Number < 0)
            //{
            //    throw new ErrorMsgException("任务已经被领取完了");
            //}

            var orderInfo = new OrderInfo
            {
                Id         = Guid.NewGuid(),
                TaskInfoId = this.TaskInfo.Id,
                IDFA       = this.ClientInfo.IDFA,
                IPAddress  = this.ClientInfo.IpAddress,
                Status     = Data.Enums.OrderStatus.已领取,
                CreateTime = DateTime.Now,
                UserId     = this.ClientInfo.UserId,
                Money      = this.TaskInfo.Money
            };

            //dataAccess.Update(this.TaskInfo);
            dataAccess.Add(orderInfo);
            dataAccess.SaveChanges();

            return(orderInfo);
            //}
        }
示例#2
0
 public bool Add(T model)
 {
     return(repository.Add(model));
 }
 public async Task <Result> Add(Result result)
 {
     return(await _baseRepository.Add(result));
 }
示例#4
0
 public void Add(TEntity model)
 {
     baseDal.Add(model);
 }
示例#5
0
 public int SaveMedioCobro(MedioCobro emp)
 {
     _MedioCobroRepository.Add(emp);
     SlsContext.SaveChanges();
     return(1);
 }
示例#6
0
 public bool Add(TEntity entity)
 {
     return(repository.Add(entity));
 }
示例#7
0
 public virtual async Task <bool> Add(TEntity entity)
 {
     return(await _repository.Add(entity));
 }
 public int SaveTipoDocumento(TipoDocumento emp)
 {
     _TipoDocumentoRepository.Add(emp);
     SlsContext.SaveChanges();
     return(1);
 }
 public E Add(E entity)
 {
     return(repository.Add(entity));
 }
示例#10
0
 public Guid Add(TEntity entity)
 {
     return(repository.Add(entity));
 }
示例#11
0
        /// <summary>
        /// 新增群組信息
        /// </summary>
        /// <param name="Data"></param>
        /// <param name="Accounts"></param>
        /// <returns></returns>
        public Boolean CreateTechnicianGroup(TtechnicianGroup Data, String[] Accounts)
        {
            //_logger.Info($"新增群組-群組名稱:{Data.GroupName}");

            #region 檢核群組信息是否重复

            var con = new Conditions <DataBase.TTechnicianGroup>();

            con.And(x => x.CompCd == Data.CompCd &&
                    x.VendorCd == Data.VendorCd &&
                    x.GroupName == Data.GroupName);

            //if (_technicianGroupRepo.IsExist(con))
            //    throw new IndexOutOfRangeException("[ERROR]=>新增群組,檢核已有該群組存在");

            #endregion

            using (TransactionScope scope = new TransactionScope())
            {
                _logger.Info($"新增群組-準備更新資料");

                #region 新增群組
                if (_technicianGroupRepo.IsExist(con))
                {
                    throw new Exception("群組名稱相同");
                }

                _technicianGroupRepo.Add(con, Data);

                var seq = _technicianGroupRepo.Get(con).Seq;

                #endregion

                #region 新增技師至群組

                if (Accounts != null)
                {
                    foreach (String account in Accounts)
                    {
                        TtechnicianGroupClaims technicianGroupClaims = new TtechnicianGroupClaims()
                        {
                            Seq      = seq,
                            CompCd   = Data.CompCd,
                            VendorCd = Data.VendorCd,
                            Account  = account
                        };

                        var cond = new Conditions <DataBase.TTechnicianGroupClaims>();
                        cond.And(x => x.Seq == seq &&
                                 x.CompCd == Data.CompCd &&
                                 x.VendorCd == Data.VendorCd &&
                                 x.Account == account);
                        if (!_technicianGroupClaimsRepo.Add(cond, technicianGroupClaims))
                        {
                            throw new Exception("[ERROR]=>新增技師至群組時,新增失敗");
                        }
                    }
                }

                #endregion

                scope.Complete();
            }
            return(true);
        }
示例#12
0
 public void Add(TEntityDTO entity)
 {
     _repository.Add(entity);
 }
示例#13
0
 public void Add(Assunto obj)
 {
     _repository.Add(obj);
 }
示例#14
0
 public IActionResult Post(Posteo posteo)
 {
     _repo.Add(posteo);
     _repo.Save();
     return(new CreatedResult(posteo.Id.ToString(), posteo));
 }
示例#15
0
 /// <summary>
 /// 写入实体
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public async Task <bool> Add(TEntity model)
 {
     return(await baseDal.Add(model));
 }
示例#16
0
 /// <summary>
 /// 写入实体数据
 /// </summary>
 /// <param name="entity">博文实体类</param>
 /// <returns></returns>
 public async Task <int> Add(TEntity entity, bool isReturnId)
 {
     return(await BaseDal.Add(entity, isReturnId));
 }
示例#17
0
 public void Add(TEntity entity)
 {
     _reponsitory.Add(entity);
 }
示例#18
0
 public void InsertEducationItem(EducationItem t)
 {
     _educationItemRepo.Add(t);
 }
示例#19
0
 /// <summary>
 /// 写入实体数据
 /// </summary>
 /// <param name="entity">博文实体类</param>
 /// <returns></returns>
 public async Task <int> Add(TEntity entity)
 {
     return(await baseDal.Add(entity));
 }
示例#20
0
 public async Task <bool> Add(TEntity entity)
 {
     return(await _BaseRepository.Add(entity));
 }
示例#21
0
 public void Add(TEntity obj)
 {
     _repository.Add(obj);
 }
        public virtual async Task <int> Add(TDto dto)
        {
            await currentRepository.Add(mapper.Map <TEntity>(dto));

            return(await unitOfWork.SaveChangesAsync());
        }
示例#23
0
 /// <summary>
 /// Adding a new user to database
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public int AddUser(User user)
 {
     _userRepository.Add(user);
     _userRepository.Save();
     return(user.Id);
 }
示例#24
0
        public ActionResult RegisterCustomer(CustomerViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    #region if customer still exists, it won't add

                    var customer = _customerRepository.GetAll().FirstOrDefault(c => c.Email == model.Email);
                    if (customer != null)
                    {
                        ViewData["errorMessage"] = "customer already exists";
                        return(View(model));
                    }

                    #endregion

                    #region create a new customer
                    var newCustomer = new Customer()
                    {
                        Firstname      = model.Firstname,
                        Lastname       = model.Lastname,
                        Email          = model.Email,
                        CitizenNumber  = model.CitizenNumber,
                        BirthDate      = model.BirthDate,
                        City           = model.City,
                        Country        = model.Country,
                        Gender         = model.Gender,
                        LicenseOrigin  = model.LicenseOrigin,
                        Mobile         = model.Mobile,
                        PassportNumber = model.PassportNumber,
                        Location       = model.Location,
                        UniqueKey      = Guid.NewGuid(),
                        CreatedDate    = DateTime.Now
                    };
                    #endregion

                    ViewData["errorMessage"]   = null;
                    ViewData["successMessage"] = "Ok";

                    _customerRepository.Add(newCustomer);
                    _unitOfWork.Commit();
                    return(RedirectToAction("Index", "Customer"));
                }
                catch (Exception ex)
                {
                    ViewData["errorMessage"] = ex.Message;
                    var exception = new Error()
                    {
                        DateCreated = DateTime.Now,
                        Message     = ex.Message,
                        StackTrace  = ex.StackTrace
                    };
                    _errorsRepository.Add(exception);
                    _unitOfWork.Commit();
                }
            }
            else
            {
                var errors = ViewData.ModelState.Where(n => n.Value.Errors.Count > 0).ToList();
            }

            return(View(model));
        }
 public int SaveTipoMoneda(TipoMoneda emp)
 {
     _TipoMonedaRepository.Add(emp);
     SlsContext.SaveChanges();
     return(1);
 }
示例#26
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public Task <int> Add(T model)
 {
     return(baseRepository.Add(model));
 }
示例#27
0
 /// <summary>
 /// 新增一个数据库模型
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public async Task <TEntity> Add(TEntity model)
 {
     return(await BaseDal.Add(model));
 }
示例#28
0
        public async Task <MessageModel <string> > TestTranInRepository()
        {
            try
            {
                Console.WriteLine($"");
                Console.WriteLine($"事务操作开始");
                _unitOfWork.BeginTran();
                Console.WriteLine($"");

                Console.WriteLine($"insert a data into the table PasswordLib now.");
                var insertPassword = await _passwordLibRepository.Add(new PasswordLib()
                {
                    IsDeleted     = false,
                    plAccountName = "aaa",
                    plCreateTime  = DateTime.Now
                });


                var passwords = await _passwordLibRepository.Query(d => d.IsDeleted == false);

                Console.WriteLine($"second time : the count of passwords is :{passwords.Count}");

                //......

                Console.WriteLine($"");
                var guestbooks = await _dal.Query();

                Console.WriteLine($"first time : the count of guestbooks is :{guestbooks.Count}");

                int ex = 0;
                Console.WriteLine($"\nThere's an exception!!");
                int throwEx = 1 / ex;

                Console.WriteLine($"insert a data into the table Guestbook now.");
                var insertGuestbook = await _dal.Add(new Guestbook()
                {
                    username   = "******",
                    blogId     = 1,
                    createdate = DateTime.Now,
                    isshow     = true
                });

                guestbooks = await _dal.Query();

                Console.WriteLine($"second time : the count of guestbooks is :{guestbooks.Count}");


                _unitOfWork.CommitTran();

                return(new MessageModel <string>()
                {
                    success = true,
                    msg = "操作完成"
                });
            }
            catch (Exception)
            {
                _unitOfWork.RollbackTran();
                var passwords = await _passwordLibRepository.Query();

                Console.WriteLine($"third time : the count of passwords is :{passwords.Count}");

                var guestbooks = await _dal.Query();

                Console.WriteLine($"third time : the count of guestbooks is :{guestbooks.Count}");

                return(new MessageModel <string>()
                {
                    success = false,
                    msg = "操作异常"
                });
            }
        }
示例#29
0
        public ResultEntity <TEntity> Add(TEntity entity)
        {
            _repository.Add(entity);

            return(ResultEntity <TEntity> .Success(entity));
        }
示例#30
0
 public TBLLEntity Add(TBLLEntity entity)
 {
     return(_mapper.Map <TBLLEntity>(
                ServiceRepository.Add(_mapper.Map <TDALEntity>(entity))));
 }