Exemplo n.º 1
0
        public Int32 PostCollectionPayment(TrnCollectionPayment collectionPayment)
        {
            try
            {
                var currentUser = from d in db.MstUsers
                                  where d.AspNetId == User.Identity.GetUserId()
                                  select d;

                if (currentUser.Any())
                {
                    var collection = from d in db.TrnCollections
                                     where d.Id == collectionPayment.CollectionId
                                     select d;

                    if (collection.Any())
                    {
                        Data.TrnCollectionPayment newCollectionPayment = new Data.TrnCollectionPayment()
                        {
                            CollectionId             = collectionPayment.CollectionId,
                            SoldUnitId               = collectionPayment.SoldUnitId,
                            SoldUnitEquityScheduleId = collectionPayment.SoldUnitEquityScheduleId,
                            PayType          = collectionPayment.PayType,
                            Amount           = collectionPayment.Amount,
                            CheckNumber      = collectionPayment.CheckNumber,
                            CheckDate        = Convert.ToDateTime(collectionPayment.CheckDate),
                            CheckBank        = collectionPayment.CheckBank,
                            OtherInformation = collectionPayment.OtherInformation
                        };

                        db.TrnCollectionPayments.InsertOnSubmit(newCollectionPayment);
                        db.SubmitChanges();

                        return(1);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(0);
            }
        }
Exemplo n.º 2
0
        public HttpResponseMessage UpdateCollectionPayment(TrnCollectionPayment collectionPayment)
        {
            try
            {
                var currentUser = from d in db.MstUsers
                                  where d.AspNetId == User.Identity.GetUserId()
                                  select d;

                if (currentUser.Any())
                {
                    var currentCollectionPayments = from d in db.TrnCollectionPayments where d.Id == Convert.ToInt32(collectionPayment.Id) select d;

                    if (currentCollectionPayments.Any())
                    {
                        var updateCollectionPayment = currentCollectionPayments.FirstOrDefault();
                        updateCollectionPayment.SoldUnitId = collectionPayment.SoldUnitId;
                        updateCollectionPayment.SoldUnitEquityScheduleId = collectionPayment.SoldUnitEquityScheduleId;
                        updateCollectionPayment.PayType          = collectionPayment.PayType;
                        updateCollectionPayment.Amount           = collectionPayment.Amount;
                        updateCollectionPayment.CheckNumber      = collectionPayment.CheckNumber;
                        updateCollectionPayment.CheckDate        = Convert.ToDateTime(collectionPayment.CheckDate);
                        updateCollectionPayment.CheckBank        = collectionPayment.CheckNumber;
                        updateCollectionPayment.OtherInformation = collectionPayment.OtherInformation;
                        db.SubmitChanges();

                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.BadRequest, "Collection not exist!"));
                    }
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest));
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }