public void TestValid()
        {
            basic_api_collection.Models.Collection coll = new basic_api_collection.Models.Collection("hu3", 10, "tao");
            CollectionBO bo = new CollectionBO(coll);

            Assert.True(bo.Valid());
        }
        public void TestInvalidSubIndice()
        {
            basic_api_collection.Models.Collection coll = new basic_api_collection.Models.Collection("hu3", -1, "tao");
            CollectionBO bo = new CollectionBO(coll);

            Assert.False(bo.Valid());
        }
        public void TestAddFalse()
        {
            basic_api_collection.Models.Collection coll = new basic_api_collection.Models.Collection("", 5, "tao");
            CollectionBO bo = new CollectionBO(coll);

            Assert.False(bo.Add());
        }
        public void TestInvalidValue()
        {
            basic_api_collection.Models.Collection coll = new basic_api_collection.Models.Collection("hu3", 10, "");
            CollectionBO bo = new CollectionBO(coll);

            Assert.False(bo.Valid());
        }
Esempio n. 5
0
        internal string GetTodaysCashCollection(CollectionBO collectionBO)
        {
            DataAccessSqlHelper sqlHelper = new DataAccessSqlHelper(collectionBO.ConString);
            SqlCommand          command   = sqlHelper.CreateCommand(CommandType.Text);

            command.CommandText = "SELECT  ISNULL(SUM(Amount),0) Amount from paymentheader where CONVERT(varchar(100),paymentdate,103) = CONVERT(varchar(100),getdate(),103) and paymentModeId = 1 and CollectedBy = " + collectionBO.CollectedBy;
            return(Convert.ToString(sqlHelper.ExecuteScalar(command)));
        }
Esempio n. 6
0
 public IActionResult Post([FromBody] CollectionBO collection)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     return(Ok(facade.GetCollectionService.Create(collection)));
 }
Esempio n. 7
0
 public CollectionBO Create(CollectionBO collection)
 {
     using (var uow = facade.UnitOfWork)
     {
         var newCollection = uow.CollectionRepository.Create(conv.Convert(collection));
         uow.Complete();
         return(conv.Convert(newCollection));
     }
 }
        public ActionResult UpdateCollection(int id = 0)
        {
            CollectionBO model = new CollectionBO();

            if (id > 0)
            {
                model = CollectionDAO.GetCollectionByID(id);
            }
            return(View(model));
        }
Esempio n. 9
0
        internal DataSet GetCollectionDetails(CollectionBO collectionBO)
        {
            DataAccessSqlHelper sqlHelper = new DataAccessSqlHelper(collectionBO.ConString);
            SqlCommand          command   = sqlHelper.CreateCommand(CommandType.StoredProcedure);

            command.CommandText = "getInvoiceorCollectionDetails";
            sqlHelper.AddParameter(command, "@Mode", collectionBO.Mode, ParameterDirection.Input);
            sqlHelper.AddParameter(command, "@ReceiptNo", collectionBO.ReceiptNo, ParameterDirection.Input);
            return(sqlHelper.ExecuteDataSet(command));
        }
Esempio n. 10
0
        internal int GetCollectionCount(CollectionBO collectionBO)
        {
            DataAccessSqlHelper sqlHelper = new DataAccessSqlHelper(collectionBO.ConString);
            SqlCommand          command   = sqlHelper.CreateCommand(CommandType.StoredProcedure);

            command.CommandText = "uspWSGetCollectionCount";
            sqlHelper.AddParameter(command, "@UserId", collectionBO.UserId, ParameterDirection.Input);
            sqlHelper.AddParameter(command, "@OrderDate", collectionBO.InstrumentDate.ToString(), ParameterDirection.Input);
            return(Convert.ToInt32(sqlHelper.ExecuteScalar(command)));
        }
Esempio n. 11
0
        public ActionResult UpdateCollection(CollectionBO collectionModel)
        {
            if (ModelState.IsValid)
            {
                UserLogin user         = (UserLogin)Session[CommonConstants.USER_SESSION];
                string    errorMessage = "";
                bool      result       = false;
                collectionModel.isdeleted = 0;
                if (collectionModel.id > 0)
                {
                    //get updatemodel
                    CollectionBO newUpdateBO = new CollectionBO();
                    newUpdateBO = CollectionDAO.GetCollectionByID(collectionModel.id);
                    if (newUpdateBO == null)
                    {
                        ModelState.AddModelError("", "Collection không tồn tại");
                        return(View(collectionModel));
                    }

                    newUpdateBO.updateduser     = user.UserID.ToString();
                    newUpdateBO.updateddate     = DateTime.Now;
                    newUpdateBO.description     = collectionModel.description;
                    newUpdateBO.keyword         = collectionModel.keyword;
                    newUpdateBO.logo            = collectionModel.logo;
                    newUpdateBO.metadescription = collectionModel.metadescription;
                    newUpdateBO.metakeyword     = collectionModel.metakeyword;
                    newUpdateBO.name            = collectionModel.name;
                    newUpdateBO.seoname         = collectionModel.seoname;
                    newUpdateBO.displayorder    = collectionModel.displayorder;

                    result = CollectionDAO.UpdateCollection(newUpdateBO, ref errorMessage);
                    SetAlert($"Cập nhật Collection {collectionModel.id}-{collectionModel.name} thành công", "success");
                }
                else
                {
                    collectionModel.createduser = user.UserID.ToString();
                    collectionModel.createddate = DateTime.Now;
                    result = CollectionDAO.InsertCollection(collectionModel, ref errorMessage);
                    SetAlert($"Thêm Collection {collectionModel.name} thành công", "success");
                }

                if (result)
                {
                    return(RedirectToAction("Collection", "Category"));
                }
                else
                {
                    ModelState.AddModelError("", "Có lỗi xảy ra. Thêm thất bại: " + errorMessage);
                }
            }

            return(View(collectionModel));
        }
        public void TestRemove()
        {
            string key = "hu3";

            basic_api_collection.Models.Collection coll = new basic_api_collection.Models.Collection(key, 5, "tao");
            CollectionBO bo = new CollectionBO(coll);

            bo.Add();

            Assert.True(bo.Remove(key));
            Assert.False(bo.Remove(key + "dasijdasi"));
        }
        public void TestAdd()
        {
            string key = "hu33";

            basic_api_collection.Models.Collection coll = new basic_api_collection.Models.Collection(key, 0, "tao");
            CollectionBO bo = new CollectionBO(coll);

            Assert.True(bo.Add());

            var list = bo.Get(key, 0, 0);

            Assert.Equal(1, list.Count);
        }
        public void TestRemoveValuesFromSubIndex()
        {
            string key       = "hu3";
            int    subIndice = 10;

            basic_api_collection.Models.Collection coll = new basic_api_collection.Models.Collection(key, subIndice, "tao");
            CollectionBO bo = new CollectionBO(coll);

            bo.Add();

            Assert.True(bo.RemoveValuesFromSubIndex(key, subIndice));
            Assert.False(bo.RemoveValuesFromSubIndex(key, subIndice + 1));
            Assert.False(bo.RemoveValuesFromSubIndex(key + "hu3", subIndice));
        }
Esempio n. 15
0
 public CollectionBO Update(CollectionBO collection)
 {
     using (var uow = facade.UnitOfWork)
     {
         var CollectionFromDB = uow.CollectionRepository.RetrieveCollection(collection.CollectionId);
         if (CollectionFromDB == null)
         {
             throw new InvalidOperationException("Collection not found.");
         }
         CollectionFromDB.CreatedDate = collection.CreatedDate;
         uow.Complete();
         return(conv.Convert(CollectionFromDB));
     }
 }
Esempio n. 16
0
 public IActionResult Put(int id, [FromBody] CollectionBO collection)
 {
     if (id != collection.CollectionId)
     {
         return(StatusCode(405, "Path Id does not match Movie ID in json object"));
     }
     try
     {
         return(Ok(facade.GetCollectionService.Update(collection)));
     }
     catch (InvalidOperationException e)
     {
         return(StatusCode(404, e.Message));
     }
 }
Esempio n. 17
0
 internal Collection Convert(CollectionBO collection)
 {
     if (collection == null)
     {
         return(null);
     }
     return(new Collection()
     {
         CollectionId = collection.CollectionId,
         CreatedDate = collection.CreatedDate,
         Name = collection.Name,
         Movies = collection.Movies.ConvertAll(x => new Movie {
             Id = x.Id, Genre = x.Genre, Name = x.Name
         })
     });
 }
Esempio n. 18
0
        public static bool InsertCollection(CollectionBO collectionModel, ref string errorMessage)
        {
            try
            {
                //tao id: lay id max hien tai+1
                collectionModel.id = GetMaxCollectionID() + 1;

                var collection = MongoClientHelper.Current.ConnectDatabase().GetCollection <CollectionBO>("collection");

                collection.InsertOne(collectionModel);
                return(true);
            }
            catch (Exception ex)
            {
                errorMessage = ex.ToString();
                return(false);
            }
        }
        public void TestindexOf()
        {
            string key    = "hu31";
            string value  = "anyValue";
            string value1 = "anyValue2";

            basic_api_collection.Models.Collection coll = new basic_api_collection.Models.Collection(key, 10, value);
            CollectionBO bo = new CollectionBO(coll);

            bo.Add();

            coll = new basic_api_collection.Models.Collection(key, 12, value1);
            bo   = new CollectionBO(coll);
            bo.Add();

            Assert.Equal(0, bo.IndexOf(key, value));
            Assert.Equal(1, bo.IndexOf(key, value1));
            Assert.Equal(0, bo.IndexOf(key, "didn't exists"));
        }
Esempio n. 20
0
        public static bool UpdateCollection(CollectionBO newUpdateBO, ref string errorMessage)
        {
            try
            {
                var collection    = MongoClientHelper.Current.ConnectDatabase().GetCollection <CollectionBO>("collection");
                var filterBuilder = Builders <CollectionBO> .Filter;
                var filter        = filterBuilder.Eq("id", newUpdateBO.id);

                var result = collection.ReplaceOne(filter, newUpdateBO);
                if (result.IsAcknowledged)
                {
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                errorMessage = ex.ToString();
                return(false);
            }
        }
Esempio n. 21
0
        public static CollectionBO GetCollectionByID(int id)
        {
            try
            {
                CollectionBO _collection   = new CollectionBO();
                var          collection    = MongoClientHelper.Current.ConnectDatabase().GetCollection <BsonDocument>("collection");
                var          filterBuilder = Builders <BsonDocument> .Filter;
                var          filter        = filterBuilder.Eq("isdeleted", 0) & filterBuilder.Eq("_id", id);
                var          cursor        = collection.Find(filter).FirstOrDefault();
                if (cursor == null)
                {
                    return(null);
                }

                _collection = BsonSerializer.Deserialize <CollectionBO>(cursor);

                return(_collection);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public CollectionsController()
 {
     this.Bo = new CollectionBO();
 }
 public bool Add(string key, int subIndex, string value)
 {
     this.Bo = new CollectionBO(new Collection(key, subIndex, value));
     return(this.Bo.Add());
 }
Esempio n. 24
0
        internal int UpdateCollection(CollectionBO collectionBO)
        {
            DataAccessSqlHelper sqlHelper = new DataAccessSqlHelper(collectionBO.ConString);
            SqlCommand          command   = sqlHelper.CreateCommand(CommandType.StoredProcedure);

            if (collectionBO.BillNo.Equals(""))
            {
                command.CommandText = "uspPaymentHeader"; //"uspWSUpdateCollectionDetails";
                sqlHelper.AddParameter(command, "@Mode", collectionBO.Mode, ParameterDirection.Input);
                sqlHelper.AddParameter(command, "@ShopID", collectionBO.ShopId, ParameterDirection.Input);
                sqlHelper.AddParameter(command, "@CollectedBy", collectionBO.CollectedBy, ParameterDirection.Input);
                sqlHelper.AddParameter(command, "@Amount", collectionBO.TotalAmount, ParameterDirection.Input);
                //sqlHelper.AddParameter(command, "@InvoiceNo", collectionBO.InvoiceNo, ParameterDirection.Input);
                sqlHelper.AddParameter(command, "@ReceiptNo", collectionBO.ReceiptNo, ParameterDirection.Input);
                sqlHelper.AddParameter(command, "@PaymentModeId", collectionBO.PaymentModeId, ParameterDirection.Input);
                sqlHelper.AddParameter(command, "@InstrumentNo", collectionBO.InstrumentNo, ParameterDirection.Input);
                sqlHelper.AddParameter(command, "@Narration", collectionBO.Narration, ParameterDirection.Input);
                sqlHelper.AddParameter(command, "@InstrumentDate", collectionBO.InstrumentDate.ToString(), ParameterDirection.Input);
                sqlHelper.AddParameter(command, "@lattitude", collectionBO.Latitude, ParameterDirection.Input);
                sqlHelper.AddParameter(command, "@longitude", collectionBO.Longitude, ParameterDirection.Input);
                sqlHelper.AddParameter(command, "@processName", collectionBO.ProcessName, ParameterDirection.Input);
                sqlHelper.AddParameter(command, "@mobilePaymentDate", collectionBO.MobilePaymentDate, ParameterDirection.Input);
                sqlHelper.AddParameter(command, "@MobileReferenceNo", collectionBO.MobileReferenceNo, ParameterDirection.Input);
                if (collectionBO.signalStrength != null && collectionBO.signalStrength != string.Empty && collectionBO.signalStrength != "")
                {
                    sqlHelper.AddParameter(command, "@signalStrength", collectionBO.signalStrength, ParameterDirection.Input);
                }
                if (collectionBO.networkProvider != null && collectionBO.networkProvider != string.Empty && collectionBO.networkProvider != "")
                {
                    sqlHelper.AddParameter(command, "@networkProvider", collectionBO.networkProvider, ParameterDirection.Input);
                }
                if (collectionBO.CollectionDiscount != "")
                {
                    sqlHelper.AddParameter(command, "@CollectionDiscount", collectionBO.CollectionDiscount, ParameterDirection.Input);
                }

                sqlHelper.AddParameter(command, "@GpsSource", collectionBO.GpsSource, ParameterDirection.Input);
                if (collectionBO.BankId != 0)
                {
                    sqlHelper.AddParameter(command, "@BankId", collectionBO.BankId, ParameterDirection.Input);
                }
                if (collectionBO.IsRemitted.Equals("1"))
                {
                    if (!collectionBO.RemittedAt.Equals(""))
                    {
                        sqlHelper.AddParameter(command, "@IsRemitted", collectionBO.IsRemitted, ParameterDirection.Input);
                        sqlHelper.AddParameter(command, "@RemittedAt", collectionBO.RemittedAt, ParameterDirection.Input);
                        sqlHelper.AddParameter(command, "@RemittedDate", DateTime.Now, ParameterDirection.Input);
                    }
                }
                if (collectionBO.MobileSyncDate != "" && collectionBO.MobileDate != "")
                {
                    sqlHelper.AddParameter(command, "@MobileSyncDate", collectionBO.MobileDate, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@ServerSyncDate", collectionBO.MobileSyncDate, ParameterDirection.Input);
                }
                if (!string.IsNullOrEmpty(collectionBO.TempShopId))
                {
                    sqlHelper.AddParameter(command, "@TempShopId", collectionBO.TempShopId, ParameterDirection.Input);
                }
            }
            else
            {
                if (collectionBO.IsMultipleDiscountCollection.Equals("true"))
                {
                    command.CommandText = "setBillWiseCollectionWithDiscount";
                    sqlHelper.AddParameter(command, "@Mode", 4, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@ShopId", collectionBO.ShopId, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@CollectedBy", collectionBO.CollectedBy, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@AmountSet", collectionBO.Amount, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@ReceiptNo", collectionBO.ReceiptNo, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@PaymentModeId", collectionBO.PaymentModeId, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@InstrumentNo", collectionBO.InstrumentNo, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@Narration", collectionBO.Narration, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@InstrumentDate", collectionBO.InstrumentDate.ToString(), ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@lattitude", collectionBO.Latitude, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@longitude", collectionBO.Longitude, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@processName", collectionBO.ProcessName, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@BillNoSet", collectionBO.BillNo, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@discountSet", collectionBO.Discount, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@OsBalanceSet", collectionBO.OsBalance, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@Amount", collectionBO.TotalAmount, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@rdDiscountSet", collectionBO.Discount1, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@sdDiscountSet", collectionBO.Discount2, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@cdDiscountSet", collectionBO.Discount3, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@mobilePaymentDate", collectionBO.MobilePaymentDate, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@MobileReferenceNo", collectionBO.MobileReferenceNo, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@GpsSource", collectionBO.GpsSource, ParameterDirection.Input);
                    if (collectionBO.signalStrength != null && collectionBO.signalStrength != string.Empty && collectionBO.signalStrength != "")
                    {
                        sqlHelper.AddParameter(command, "@signalStrength", collectionBO.signalStrength, ParameterDirection.Input);
                    }
                    if (collectionBO.networkProvider != null && collectionBO.networkProvider != string.Empty && collectionBO.networkProvider != "")
                    {
                        sqlHelper.AddParameter(command, "@networkProvider", collectionBO.networkProvider, ParameterDirection.Input);
                    }
                    //sqlHelper.AddParameter(command, "@mobilePaymentDate", DateTime.Now.ToString(), ParameterDirection.Input);
                    if (collectionBO.BankId != 0)
                    {
                        sqlHelper.AddParameter(command, "@BankIdValue", collectionBO.BankId, ParameterDirection.Input);
                    }
                    if (collectionBO.MobileSyncDate != "" && collectionBO.MobileDate != "")
                    {
                        sqlHelper.AddParameter(command, "@MobileSyncDate", collectionBO.MobileDate, ParameterDirection.Input);
                        sqlHelper.AddParameter(command, "@ServerSyncDate", collectionBO.MobileSyncDate, ParameterDirection.Input);
                    }
                    if (!string.IsNullOrEmpty(collectionBO.TempShopId))
                    {
                        sqlHelper.AddParameter(command, "@TempShopId", collectionBO.TempShopId, ParameterDirection.Input);
                    }
                }
                else
                {
                    command.CommandText = "getBillNoForBillWiseCollection";
                    sqlHelper.AddParameter(command, "@Mode", 2, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@ShopID", collectionBO.ShopId, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@CollectedBy", collectionBO.CollectedBy, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@AmountSet", collectionBO.Amount, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@ReceiptNo", collectionBO.ReceiptNo, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@PaymentModeId", collectionBO.PaymentModeId, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@InstrumentNo", collectionBO.InstrumentNo, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@Narration", collectionBO.Narration, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@InstrumentDate", collectionBO.InstrumentDate.ToString(), ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@lattitude", collectionBO.Latitude, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@longitude", collectionBO.Longitude, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@processName", collectionBO.ProcessName, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@BillNoSet", collectionBO.BillNo, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@discountSet", collectionBO.Discount, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@OsBalanceSet", collectionBO.OsBalance, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@Amount", collectionBO.TotalAmount, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@mobilePaymentDate", collectionBO.MobilePaymentDate, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@MobileReferenceNo", collectionBO.MobileReferenceNo, ParameterDirection.Input);
                    sqlHelper.AddParameter(command, "@GpsSource", collectionBO.GpsSource, ParameterDirection.Input);

                    //sqlHelper.AddParameter(command, "@mobilePaymentDate", DateTime.Now.ToString(), ParameterDirection.Input);
                    if (collectionBO.BankId != 0)
                    {
                        sqlHelper.AddParameter(command, "@BankId", collectionBO.BankId, ParameterDirection.Input);
                    }
                    if (collectionBO.MobileSyncDate != "" && collectionBO.MobileDate != "")
                    {
                        sqlHelper.AddParameter(command, "@MobileSyncDate", collectionBO.MobileDate, ParameterDirection.Input);
                        sqlHelper.AddParameter(command, "@ServerSyncDate", collectionBO.MobileSyncDate, ParameterDirection.Input);
                    }
                    if (!string.IsNullOrEmpty(collectionBO.TempShopId))
                    {
                        sqlHelper.AddParameter(command, "@TempShopId", collectionBO.TempShopId, ParameterDirection.Input);
                    }
                }
            }


            //sqlHelper.AddParameter(command, "@Discount", collectionBO.Discount, ParameterDirection.Input); ;
            return(Convert.ToInt32(sqlHelper.ExecuteNonQuery(command)));
        }