Example #1
0
 public CurrentUserModel(UserProfile user)
 {
     // this.Owner = user.DefaultHub.HubOwner.Name;
     this.Name = user.DefaultHubObj.Name;
     this.DefaultHubId = user.DefaultHubObj.HubID;
     PossibleHubs = user.UserAllowedHubs;
 }
Example #2
0
 /// <summary>
 /// constructor with the testable repositories and the user
 /// the user is required because we need to decide what wareshouses to display for her.
 /// </summary>
 public ReceiveViewModel(List<Commodity> commodities, List<CommodityGrade> commodityGrades, List<Transporter> transporters, List<CommodityType> commodityTypes,
     List<CommoditySource> commoditySources, List<Program> programs, List<Donor> donors, List<Hub> hubs, UserProfile user,List<Unit> units  )
 {
     _UserProfile = user;
     InitalizeViewModel(commodities, commodityGrades, transporters, commodityTypes,
      commoditySources, programs, donors, hubs, user, units);
 }
Example #3
0
 public bool DeleteUserProfile(UserProfile entity)
 {
     if (entity == null) return false;
     _unitOfWork.UserProfileRepository.Delete(entity);
     _unitOfWork.Save();
     return true;
 }
 public void CanDoPostBackEdit()
 {
     //ACT
     var userProfile = new UserProfile { UserProfileID = 1, UserName = "******", Password = "******", Email = "*****@*****.**" };
     var result = _adminController.Edit(userProfile);
     //Assert
     Assert.IsInstanceOf<ActionResult>(result);
     Assert.IsInstanceOf<UserProfile>(userProfile.UserProfileID.ToString(CultureInfo.InvariantCulture));
 }
Example #5
0
 public bool EditInfo(UserProfile profile)
 {
     var userPrfl = _unitOfWork.UserProfileRepository.FindBy(u => u.UserProfileID == profile.UserProfileID).SingleOrDefault();
     if (userPrfl == null) return false;
     userPrfl.FirstName = profile.FirstName;
     userPrfl.LastName = profile.LastName;
     userPrfl.GrandFatherName = profile.GrandFatherName;
     _unitOfWork.Save();
     return true;
 }
Example #6
0
        public virtual ActionResult Create(UserProfile userprofile)
        {
            if (ModelState.IsValid)
            {
                userprofile.Password = MD5Hashing.MD5Hash(userprofile.Password);
                _userProfileService.AddUserProfile(userprofile);
                return Json(new { success = true });
            }

            ViewBag.UserProfileID = new SelectList(_userRoleService.GetAllUserRole(), "UserRoleID", "UserRoleID", userprofile.UserProfileID);
            return PartialView("Users/Create", userprofile);
        }
Example #7
0
        public List<StoreViewModel> GetAllStoreByUser(UserProfile user)
        {
            if (user == null || user.DefaultHub == null)
            {
                return new List<StoreViewModel>();
            }
            //var stores = (from c in user.DefaultHub.Stores select new ViewModels.Common.StoreViewModel { StoreId = c.StoreID, StoreName = string.Format("{0} - {1} ", c.Name, c.StoreManName) }).OrderBy(c => c.StoreName).ToList();

            //=======================modified by banty=================================
            //var stores = (from c in _unitOfWork.StoreRepository.GetStoreByHub(user.DefaultHub.HubID) select new ViewModels.Common.StoreViewModel { StoreId = c.StoreID, StoreName = string.Format("{0} - {1} ", c.Name, c.StoreManName) }).OrderBy(c => c.StoreName).ToList();
            var stores = (from c in _unitOfWork.StoreRepository.Get(t=>t.HubID==user.DefaultHub) select new StoreViewModel { StoreId = c.StoreID, StoreName = string.Format("{0} - {1} ", c.Name, c.StoreManName) }).OrderBy(c => c.StoreName).ToList();

            //==============================end

            //stores.Insert(0, new ViewModels.Common.StoreViewModel { StoreName = "Total Hub" });  //I need it for report only so I will modify it on report
            return stores;
        }
Example #8
0
        /// <summary>
        /// Commits the receive allocation.
        /// </summary>
        /// <param name="checkedRecords">The checked records.</param>
        /// <param name="user"></param>
        public void CommitReceiveAllocation(string[] checkedRecords, UserProfile user)
        {
            var db1 = ((IObjectContextAdapter)_unitOfWork).ObjectContext;
            var st = db1.CreateObjectSet<ReceiptAllocation>();
            foreach (string id in checkedRecords)
            {
                //Modified Banty:24/5/2013 to support dbcontext

                //db.ReceiptAllocations.MergeOption  = MergeOption.PreserveChanges;
                st.MergeOption = MergeOption.PreserveChanges;

                //ReceiptAllocation original = db.ReceiptAllocations.FirstOrDefault(p => p.ReceiptAllocationID == Guid.Parse(id));
                var original = st.FirstOrDefault(t => t.ReceiptAllocationID == Guid.Parse(id));

                if (original != null)
                {
                    original.IsCommited = true;
                    db1.SaveChanges();
                    st.MergeOption = MergeOption.NoTracking;
                }
                st.MergeOption = MergeOption.NoTracking;
            }
        }
Example #9
0
        public List<StackEventLogViewModel> GetAllStackEventsByStoreIdStackId(UserProfile user, int StackId, int StoreId)
        {
            var stackEvents = _unitOfWork.StackEventRepository.Get(c => c.StackNumber == StackId && c.StoreID == StoreId);

            var events = (from c in stackEvents select new StackEventLogViewModel { EventDate = c.EventDate, StackEventType = c.StackEventType.Name, Description = c.Description, Recommendation = c.Recommendation, FollowUpDate = c.FollowUpDate.Value }).ToList();
            return events;
        }
Example #10
0
        public List<StackEventLogViewModel> GetAllStackEvents(UserProfile user)
        {
            var StackEvents = _unitOfWork.StackEventRepository.Get();
            var events = (from c in StackEvents select new StackEventLogViewModel { EventDate = c.EventDate, StackEventType = c.StackEventType.Name, Description = c.Description, Recommendation = c.Recommendation, FollowUpDate = c.FollowUpDate.Value }).ToList();

            return events;
        }
Example #11
0
        /// <summary>
        /// Saves the receipt transaction.
        /// </summary>
        /// <param name="receiveModels">The receive models.</param>
        /// <param name="user">The user.</param>
        public Boolean SaveReceiptTransaction(ReceiveViewModel receiveModels, UserProfile user, Boolean reverse=false)
        {
            // Populate more details of the reciept object
            // Save it when you are done.
            int transactionsign = reverse ? -1 : 1;
            Receive receive;

            if(receiveModels.ReceiveID!=null)
            {
                receive = _unitOfWork.ReceiveRepository.FindById(receiveModels.ReceiveID.GetValueOrDefault());
            }
            else
            {
                receive=new Receive();
                receive = receiveModels.GenerateReceive();
            }

            receive.CreatedDate = DateTime.Now;
            receive.HubID = user.DefaultHubObj.HubID;
            receive.UserProfileID = user.UserProfileID;

            int? donorId = receive.SourceDonorID;
            var commType = _unitOfWork.CommodityTypeRepository.FindById(receiveModels.CommodityTypeID);

            // var comms = GenerateReceiveDetail(commodities);

            var transactionGroupId = Guid.NewGuid();

            receive.ReceiveDetails.Clear();

            foreach (ReceiveDetailViewModel c in receiveModels.ReceiveDetails)
            {
                if (commType.CommodityTypeID == 2)//if it's a non food
                {
                    c.ReceivedQuantityInMT = 0;
                    c.SentQuantityInMT = 0;
                }

                TransactionGroup tgroup = new TransactionGroup();
                tgroup.TransactionGroupID = transactionGroupId;
                var receiveDetail = new ReceiveDetail()
                {
                    CommodityID = c.CommodityID,
                    Description = c.Description,
                    SentQuantityInMT = c.SentQuantityInMT.Value,
                    SentQuantityInUnit = c.SentQuantityInUnit.Value,
                    UnitID = c.UnitID,
                    ReceiveID = receive.ReceiveID,
                    ReceiveDetailID = Guid.NewGuid()
                };
                //if (c.ReceiveDetailID.HasValue&&!reverse)
                //{
                //    receiveDetail.ReceiveDetailID = c.ReceiveDetailID.Value;
                //}

                receiveDetail.TransactionGroupID = tgroup.TransactionGroupID;
                receiveDetail.TransactionGroup = tgroup;
                receive.ReceiveDetails.Add(receiveDetail);

                #region physical stock movement
                //transaction for goods on hand // previously it was GOODS_ON_HAND_UNCOMMITED
                var transaction = new Transaction();
                transaction.TransactionID = Guid.NewGuid();
                transaction.TransactionGroupID = transactionGroupId;
                transaction.TransactionDate = DateTime.Now;
                transaction.ParentCommodityID = _unitOfWork.CommodityRepository.FindById(c.CommodityID).ParentID ?? c.CommodityID;
                transaction.CommodityID = c.CommodityID;
                transaction.LedgerID = Cats.Models.Ledger.Constants.GOODS_ON_HAND;
                transaction.HubOwnerID = user.DefaultHubObj.HubOwnerID;

                transaction.DonorID = donorId;

                transaction.AccountID = _accountService.GetAccountIdWithCreate(Account.Constants.HUB, receive.HubID);
                transaction.ShippingInstructionID = _shippingInstructionService.GetSINumberIdWithCreate(receiveModels.SINumber).ShippingInstructionID;

                transaction.ProjectCodeID = _projectCodeService.GetProjectCodeIdWIthCreate(receiveModels.ProjectNumber).ProjectCodeID;
                transaction.HubID = user.DefaultHubObj.HubID;
                transaction.UnitID = c.UnitID;
                if (c.ReceivedQuantityInMT != null) transaction.QuantityInMT = transactionsign * c.ReceivedQuantityInMT.Value;
                if (c.ReceivedQuantityInUnit != null) transaction.QuantityInUnit = transactionsign * c.ReceivedQuantityInUnit.Value;
                if (c.CommodityGradeID != null) transaction.CommodityGradeID = c.CommodityGradeID.Value;

                transaction.ProgramID = receiveModels.ProgramID;
                transaction.StoreID = receiveModels.StoreID;
                transaction.Stack = receiveModels.StackNumber;
                transaction.TransactionGroupID = tgroup.TransactionGroupID;
                tgroup.Transactions.Add(transaction);

                var transaction2 = new Transaction();
                transaction2.TransactionID = Guid.NewGuid();
                transaction2.TransactionGroupID = transactionGroupId;
                transaction2.TransactionDate = DateTime.Now;

                transaction2.ParentCommodityID = transaction.ParentCommodityID;
                transaction2.CommodityID = c.CommodityID;
                transaction2.HubOwnerID = user.DefaultHubObj.HubOwnerID;

                transaction2.LedgerID = Cats.Models.Ledger.Constants.GOODS_UNDER_CARE;
                if (receive.ResponsibleDonorID != null)
                    transaction2.AccountID = _accountService.GetAccountIdWithCreate(Account.Constants.DONOR, receive.ResponsibleDonorID.Value);

                //Decide from where the -ve side of the transaction comes from
                //it is either from the allocated stock
                // or it is from goods under care.

                // this means that this receipt is done without having gone through the gift certificate process.

                if (receiveModels.CommoditySourceID == CommoditySource.Constants.DONATION || receiveModels.CommoditySourceID == CommoditySource.Constants.LOCALPURCHASE)
                {
                    transaction2.LedgerID = Cats.Models.Ledger.Constants.GOODS_UNDER_CARE;
                    transaction2.AccountID = _accountService.GetAccountIdWithCreate(Account.Constants.DONOR, receive.ResponsibleDonorID.Value);
                }
                else if (receiveModels.CommoditySourceID == CommoditySource.Constants.REPAYMENT)
                {
                    transaction2.LedgerID = Cats.Models.Ledger.Constants.GOODS_RECIEVABLE;
                    transaction2.AccountID = _accountService.GetAccountIdWithCreate(Account.Constants.HUB, receiveModels.SourceHubID.Value);
                }
                else
                {
                    transaction2.LedgerID = Cats.Models.Ledger.Constants.LIABILITIES;
                    transaction2.AccountID = _accountService.GetAccountIdWithCreate(Account.Constants.HUB, receiveModels.SourceHubID.Value);
                }

                transaction2.DonorID = donorId;

                transaction2.ShippingInstructionID = _shippingInstructionService.GetSINumberIdWithCreate(receiveModels.SINumber).ShippingInstructionID;
                transaction2.ProjectCodeID = _projectCodeService.GetProjectCodeIdWIthCreate(receiveModels.ProjectNumber).ProjectCodeID;
                transaction2.HubID = user.DefaultHubObj.HubID;
                transaction2.UnitID = c.UnitID;
                // this is the credit part, so make it Negative
                if (c.ReceivedQuantityInMT != null) transaction2.QuantityInMT = transactionsign*(-c.ReceivedQuantityInMT.Value);
                if (c.ReceivedQuantityInUnit != null) transaction2.QuantityInUnit = transactionsign*(-c.ReceivedQuantityInUnit.Value);
                if (c.CommodityGradeID != null) transaction2.CommodityGradeID = c.CommodityGradeID.Value;

                transaction2.ProgramID = receiveModels.ProgramID;
                transaction2.StoreID = receiveModels.StoreID;
                transaction2.Stack = receiveModels.StackNumber;
                transaction2.TransactionGroupID = tgroup.TransactionGroupID;
                tgroup.Transactions.Add(transaction2);
                #endregion

                #region plan side of the transaction
                //transaction for statistics
                transaction = new Transaction();
                transaction.TransactionID = Guid.NewGuid();
                transaction.TransactionGroupID = transactionGroupId;
                transaction.TransactionDate = DateTime.Now;
                transaction.ParentCommodityID = _unitOfWork.CommodityRepository.FindById(c.CommodityID).ParentID ?? c.CommodityID;
                transaction.CommodityID = c.CommodityID;
                transaction.DonorID = donorId;
                transaction.LedgerID = Cats.Models.Ledger.Constants.STATISTICS_FREE_STOCK;
                transaction.HubOwnerID = user.DefaultHubObj.HubOwnerID;

                transaction.AccountID = _accountService.GetAccountIdWithCreate(Account.Constants.HUB, receive.HubID);
                transaction.ShippingInstructionID = _shippingInstructionService.GetSINumberIdWithCreate(receiveModels.SINumber).ShippingInstructionID;

                transaction.ProjectCodeID = _projectCodeService.GetProjectCodeIdWIthCreate(receiveModels.ProjectNumber).ProjectCodeID;
                transaction.HubID = user.DefaultHubObj.HubID;
                transaction.UnitID = c.UnitID;
                if (c.ReceivedQuantityInMT != null) transaction.QuantityInMT = transactionsign*  c.ReceivedQuantityInMT.Value;
                if (c.ReceivedQuantityInUnit != null) transaction.QuantityInUnit = transactionsign * c.ReceivedQuantityInUnit.Value;
                if (c.CommodityGradeID != null) transaction.CommodityGradeID = c.CommodityGradeID.Value;

                transaction.ProgramID = receiveModels.ProgramID;
                transaction.StoreID = receiveModels.StoreID;
                transaction.Stack = receiveModels.StackNumber;
                transaction.TransactionGroupID = tgroup.TransactionGroupID;
                tgroup.Transactions.Add(transaction);

                // transaction for Receivable
                transaction2 = new Transaction();
                transaction2.TransactionID = Guid.NewGuid();
                transaction2.TransactionGroupID = transactionGroupId;
                transaction2.TransactionDate = DateTime.Now;
                //TAKEs the PARENT FROM THE FIRST TRANSACTION
                transaction2.ParentCommodityID = transaction.ParentCommodityID;
                transaction2.CommodityID = c.CommodityID;
                transaction2.DonorID = donorId;
                transaction2.HubOwnerID = user.DefaultHubObj.HubOwnerID;

                transaction2.LedgerID = Cats.Models.Ledger.Constants.GOODS_RECIEVABLE;
                if (receive.ResponsibleDonorID != null)
                    transaction2.AccountID = _accountService.GetAccountIdWithCreate(Account.Constants.DONOR, receive.ResponsibleDonorID.Value);

                //Decide from where the -ve side of the transaction comes from
                //it is either from the allocated stock
                // or it is from goods under care.

                // this means that this receipt is done without having gone through the gift certificate process.

                #region "commented out"
                if (receiveModels.CommoditySourceID == CommoditySource.Constants.DONATION || receiveModels.CommoditySourceID == CommoditySource.Constants.LOCALPURCHASE)
                {
                    transaction2.LedgerID = Cats.Models.Ledger.Constants.GOODS_UNDER_CARE;
                    transaction2.AccountID = _accountService.GetAccountIdWithCreate(Account.Constants.DONOR, receive.ResponsibleDonorID.Value);
                }
                else if (receiveModels.CommoditySourceID == CommoditySource.Constants.REPAYMENT)
                {
                    transaction2.LedgerID = Cats.Models.Ledger.Constants.GOODS_RECIEVABLE;
                    transaction2.AccountID = _accountService.GetAccountIdWithCreate(Account.Constants.HUB, receiveModels.SourceHubID.Value);
                }
                else
                {
                    transaction2.LedgerID = Cats.Models.Ledger.Constants.LIABILITIES;
                    transaction2.AccountID = _accountService.GetAccountIdWithCreate(Account.Constants.HUB, receiveModels.SourceHubID.Value);
                }
                #endregion

                transaction2.ShippingInstructionID = _shippingInstructionService.GetSINumberIdWithCreate(receiveModels.SINumber).ShippingInstructionID;
                transaction2.ProjectCodeID = _projectCodeService.GetProjectCodeIdWIthCreate(receiveModels.ProjectNumber).ProjectCodeID;
                transaction2.HubID = user.DefaultHubObj.HubID;
                transaction2.UnitID = c.UnitID;
                // this is the credit part, so make it Negative
                if (c.ReceivedQuantityInMT != null) transaction2.QuantityInMT = transactionsign * (- c.ReceivedQuantityInMT.Value);
                if (c.ReceivedQuantityInUnit != null) transaction2.QuantityInUnit = transactionsign * (-c.ReceivedQuantityInUnit.Value);
                if (c.CommodityGradeID != null) transaction2.CommodityGradeID = c.CommodityGradeID.Value;

                transaction2.ProgramID = receiveModels.ProgramID;
                transaction2.StoreID = receiveModels.StoreID;
                transaction2.Stack = receiveModels.StackNumber;
                transaction2.TransactionGroupID = tgroup.TransactionGroupID;
                // hack to get past same key object in context error
                //repository.Transaction = new TransactionRepository();
                tgroup.Transactions.Add(transaction2);

                #endregion
            }

            try
            {
                if(!reverse)
                {
                    if(receiveModels.ReceiveID==null)
                    {
                        _unitOfWork.ReceiveRepository.Add(receive);
                    }
                    else
                    {
                        _unitOfWork.ReceiveRepository.Edit(receive);
                    }

                }

                _unitOfWork.Save();
                return true;
            }
            catch (Exception exp)
            {
                //TODO: Save the exception somewhere
                throw new Exception("The Receipt Transaction Cannot be saved. <br />Detail Message :" + exp.StackTrace);

            }
        }
Example #12
0
 public virtual ActionResult Edit(UserProfile userprofile)
 {
     var cachedProfile = Session["SELECTEDUSER"] as UserProfile;
     ModelState.Remove("Password");
     if (ModelState.IsValid && cachedProfile != null)
     {
         userprofile.Password = cachedProfile.Password;
         _userProfileService.EditUserProfile(userprofile);
         Session.Remove("SELECTEDUSER");
         return Json(new { success = true });
     }
     ViewBag.UserProfileID = new SelectList(_userRoleService.GetAllUserRole(), "UserRoleID", "UserRoleID", userprofile.UserProfileID);
     return PartialView("Users/Edit", userprofile);
 }
Example #13
0
        /// <summary>
        /// Generates the dipatch.
        /// </summary>
        /// <returns></returns>
        public Dispatch GenerateDipatch(UserProfile user)
        {
            //TODO:Check if any impact converting default constructor to injuct user
            //UserProfile user = Repository.UserProfile.GetUser(HttpContext.Current.User.Identity.Name);
            Dispatch dispatch = new Dispatch()
            {
                BidNumber = this.BidNumber,
                CreatedDate = DateTime.Now,
                DispatchDate = this.DispatchDate,

                DriverName = this.DriverName,
                DispatchedByStoreMan = DispatchedByStoreMan,
                FDPID = this.FDPID,
                GIN = this.GIN,
                PeriodYear = this.Year,
                PeriodMonth = this.Month,
                PlateNo_Prime = this.PlateNo_Prime,
                PlateNo_Trailer = this.PlateNo_Trailer,
                RequisitionNo = this.RequisitionNo,
                //HubID = user.DefaultHub.HubID;
                // StackNumber = this.StackNumber,
                // StoreID = this.StoreID,
                TransporterID = this.TransporterID,
                HubID = this.WarehouseID,
                //ProgramID = this.ProgramID,
                WeighBridgeTicketNumber = this.WeighBridgeTicketNumber,
                Round = this.Round,
                Remark = this.Remark,
                //ProjectNumber = this.ProjectNumber,
                // SINumber = this.SINumber
            };
            if (this.DispatchID.HasValue)
            {
                dispatch.DispatchID = this.DispatchID.Value;
            }
            return dispatch;
        }
Example #14
0
        /// <summary>
        /// </summary>
        /// <param name="viewModel"></param>
        /// <param name="user"></param>
        /// <exception cref="System.Exception"></exception>
        public void SaveLossTrasnsaction(LossesAndAdjustmentsViewModel viewModel, UserProfile user)
        {
            Commodity commodity = _unitOfWork.CommodityRepository.FindById(viewModel.CommodityId);

            Adjustment lossAndAdjustment = new Adjustment();
            TransactionGroup transactionGroup = new TransactionGroup();
            Transaction transactionOne = new Transaction();

            var transactionGroupId = Guid.NewGuid();

            transactionOne.TransactionID = Guid.NewGuid();
            transactionOne.TransactionGroupID = transactionGroupId;
            transactionOne.LedgerID = Cats.Models.Ledger.Constants.GOODS_ON_HAND;// 2;
            transactionOne.HubOwnerID = user.DefaultHubObj.HubOwner.HubOwnerID;
            transactionOne.AccountID = _accountService.GetAccountIdWithCreate(Account.Constants.HUB, user.DefaultHub.Value); //
            transactionOne.HubID = user.DefaultHub.Value;
            transactionOne.StoreID = viewModel.StoreId;  //
            transactionOne.ProjectCodeID = viewModel.ProjectCodeId;
            transactionOne.ShippingInstructionID = viewModel.ShippingInstructionId;

            transactionOne.ParentCommodityID = (commodity.ParentID == null)
                                                       ? commodity.CommodityID
                                                       : commodity.ParentID.Value;
            transactionOne.CommodityID = viewModel.CommodityId;
            transactionOne.ProgramID = viewModel.ProgramId;
            transactionOne.CommodityGradeID = null; // How did I get this value ?
            transactionOne.QuantityInMT = 0 - viewModel.QuantityInMt;
            transactionOne.QuantityInUnit = 0 - viewModel.QuantityInUint;
            transactionOne.UnitID = viewModel.UnitId;
            transactionOne.TransactionDate = DateTime.Now;

            Transaction transactionTwo = new Transaction();

            transactionTwo.TransactionID = Guid.NewGuid();
            transactionTwo.TransactionGroupID = transactionGroupId;
            transactionTwo.LedgerID = Cats.Models.Ledger.Constants.LOSS_IN_TRANSIT;// 14;
            transactionTwo.HubOwnerID = user.DefaultHubObj.HubOwnerID;
            transactionTwo.AccountID = _accountService.GetAccountIdWithCreate(Account.Constants.HUB, user.DefaultHub.Value); //
            transactionTwo.HubID = user.DefaultHub.Value;
            transactionTwo.StoreID = viewModel.StoreId;  //
            transactionTwo.ProjectCodeID = viewModel.ProjectCodeId;
            transactionTwo.ShippingInstructionID = viewModel.ShippingInstructionId;
            transactionTwo.ParentCommodityID = (commodity.ParentID == null)
                                                       ? commodity.CommodityID
                                                       : commodity.ParentID.Value;
            transactionTwo.CommodityID = viewModel.CommodityId;
            transactionTwo.ProgramID = viewModel.ProgramId;
            transactionTwo.CommodityGradeID = null; // How did I get this value ?
            transactionTwo.QuantityInMT = viewModel.QuantityInMt;
            transactionTwo.QuantityInUnit = viewModel.QuantityInUint;
            transactionTwo.UnitID = viewModel.UnitId;
            transactionTwo.TransactionDate = DateTime.Now;

            transactionGroup.TransactionGroupID = transactionGroupId;
            transactionGroup.Transactions.Add(transactionOne);
            transactionGroup.Transactions.Add(transactionTwo);

            lossAndAdjustment.PartitionId = 0;
            lossAndAdjustment.AdjustmentID = Guid.NewGuid();
            lossAndAdjustment.TransactionGroupID = transactionGroupId;
            lossAndAdjustment.TransactionGroup = transactionGroup;
            lossAndAdjustment.HubID = user.DefaultHub.Value;
            lossAndAdjustment.AdjustmentReasonID = viewModel.ReasonId;
            lossAndAdjustment.AdjustmentDirection = "L";
            lossAndAdjustment.AdjustmentDate = viewModel.SelectedDate;
            lossAndAdjustment.ApprovedBy = viewModel.ApprovedBy;
            lossAndAdjustment.Remarks = viewModel.Description;
            lossAndAdjustment.UserProfileID = user.UserProfileID;
            lossAndAdjustment.ReferenceNumber = viewModel.MemoNumber;
            lossAndAdjustment.StoreManName = viewModel.StoreMan;

            // Try to save this transaction
            try
            {
                _unitOfWork.AdjustmentRepository.Add(lossAndAdjustment);
                _unitOfWork.Save();
            }
            catch (Exception exp)
            {
                // dbTransaction.Rollback();
                //TODO: Save the detail of this exception somewhere
                throw new Exception("The Internal Movement Transaction Cannot be saved. <br />Detail Message :" + exp.Message);
            }
        }
        public List<OtherDispatchAllocationDto> GetCommitedTransferAllocationsDetached(UserProfile user, bool? closedToo, int? CommodityType)
        {
            List<OtherDispatchAllocationDto> TransferList = new List<OtherDispatchAllocationDto>();

            var Transafers = (from v in _unitOfWork.OtherDispatchAllocationRepository.Get()
                              where v.HubID == user.DefaultHub.HubID && v.Hub1.HubOwnerID == user.DefaultHub.HubOwnerID
                              select v
                        );

            if (closedToo == null || closedToo == false)
            {
                Transafers = Transafers.Where(p => p.IsClosed == false);
            }
            else
            {
                Transafers = Transafers.Where(p => p.IsClosed == true);
            }

            if (CommodityType.HasValue)
            {
                Transafers = Transafers.Where(p => p.Commodity.CommodityTypeID == CommodityType.Value);
            }
            else
            {
                Transafers = Transafers.Where(p => p.Commodity.CommodityTypeID == 1);//by default
            }

            foreach (var otherDispatchAllocation in Transafers)
            {
                var transfer = new OtherDispatchAllocationDto();

                transfer.OtherDispatchAllocationID = otherDispatchAllocation.OtherDispatchAllocationID;
                transfer.ReferenceNumber = otherDispatchAllocation.ReferenceNumber;
                transfer.CommodityName = otherDispatchAllocation.Commodity.Name;
                transfer.EstimatedDispatchDate = otherDispatchAllocation.EstimatedDispatchDate;
                transfer.AgreementDate = otherDispatchAllocation.AgreementDate;
                transfer.SINumber = otherDispatchAllocation.ShippingInstruction.Value;
                transfer.ProjectCode = otherDispatchAllocation.ProjectCode.Value;
                transfer.IsClosed = otherDispatchAllocation.IsClosed;

                transfer.QuantityInUnit = otherDispatchAllocation.QuantityInUnit;
                transfer.RemainingQuantityInUnit = otherDispatchAllocation.RemainingQuantityInUnit;

                if (user.PreferedWeightMeasurment.ToUpperInvariant() == "QN")
                {
                    transfer.QuantityInMT = Math.Abs(otherDispatchAllocation.QuantityInMT) * 10;
                    transfer.RemainingQuantityInMt = (otherDispatchAllocation.RemainingQuantityInMt) * 10;
                }
                else
                {
                    transfer.QuantityInMT = Math.Abs(otherDispatchAllocation.QuantityInMT);
                    transfer.RemainingQuantityInMt = (otherDispatchAllocation.RemainingQuantityInMt);
                }
                TransferList.Add(transfer);
            }
            return TransferList;
        }
Example #16
0
        private void PrepareEdit(Dispatch dispatch, UserProfile user, int type)
        {
            var years = (from y in _periodService.GetYears()
                         select new { Name = y, Id = y }).ToList();
            var months = (from y in _periodService.GetMonths(dispatch.PeriodYear)
                          select new { Name = y, Id = y }).ToList();
            ViewBag.Year = new SelectList(years, "Id", "Name", dispatch.PeriodYear);
            ViewBag.Month = new SelectList(months, "Id", "Name", dispatch.PeriodMonth);
            ViewData["Units"] = _unitService.GetAllUnit().Select(p => new { Id = p.UnitID, p.Name }).ToList();
            var transaction = _dispatchService.GetDispatchTransaction(dispatch.DispatchID);

            ViewBag.TransporterID = new SelectList(_transporterService.GetAllTransporter(), "TransporterID", "Name", dispatch.TransporterID);
            if (type == 1)
            {
                PrepareFDPForEdit(dispatch.FDPID);
            }
            else if (type == 2)
            {
                var tran = _dispatchService.GetDispatchTransaction(dispatch.DispatchID);
                //TODO I think there need's to be a check for this one
                ViewBag.ToHUBs = tran != null ? new SelectList(_hubService.GetAllHub().Select(p => new { Name = string.Format("{0} - {1}", p.Name, p.HubOwner.Name), HubID = p.HubID }), "HubID", "Name", tran.Account.EntityID) : null;
            }

            if (transaction != null)
            {
                ViewBag.StoreID = new SelectList(_storeService.GetStoreByHub(user.DefaultHub.Value), "StoreID", "Name", transaction.StoreID);
                ViewBag.ProgramID = new SelectList(_programService.GetAllProgram(), "ProgramID", "Name", transaction.ProgramID);
                if (transaction.Stack != null)
                    ViewBag.StackNumbers = new SelectList(transaction.Store.Stacks.Select(p => new { Name = p, Id = p }), "Id", "Name", transaction.Stack.Value);
                ViewData["Commodities"] = _commodityService.GetAllParents().Select(c => new CommodityModel { Id = c.CommodityID, Name = c.Name }).ToList();
                ViewBag.CommodityTypeID = new SelectList(_commodityTypeService.GetAllCommodityType(), "CommodityTypeID", "Name", transaction.Commodity.CommodityTypeID);
            }
            else
            {
                ViewBag.StoreID = new SelectList(_storeService.GetStoreByHub(user.DefaultHub.Value), "StoreID",
                                                 "Name"); //, transaction.StoreID);
                ViewBag.ProgramID = new SelectList(_programService.GetAllProgram(), "ProgramID", "Name");
                //, transaction.ProgramID);
                //TODO i'm not so sure about the next line
                var firstOrDefault = _storeService.GetAllStore().FirstOrDefault();
                if (firstOrDefault != null)
                    ViewBag.StackNumbers =
                        new SelectList(firstOrDefault.Stacks.Select(p => new { Name = p, Id = p }), "Id",
                                       "Name"); //, transaction.Stack.Value); )//transaction.Store.Stacks
                ViewData["Commodities"] =
                    _commodityService.GetAllParents().Select(
                        c => new CommodityModel { Id = c.CommodityID, Name = c.Name }).ToList();
                ViewBag.CommodityTypeID = new SelectList(_commodityTypeService.GetAllCommodityType(), "CommodityTypeID", "Name");
            }
            var comms = new List<DispatchDetailModel>();
            ViewBag.SelectedCommodities = comms;
        }
Example #17
0
        /// <summary>
        /// Saves the starting balance transaction.
        /// </summary>
        /// <param name="startingBalance">The starting balance.</param>
        /// <param name="user">The user.</param>
        /// <exception cref="System.Exception"></exception>
        public void SaveStartingBalanceTransaction(StartingBalanceViewModel startingBalance, UserProfile user)
        {
            int repositoryAccountGetAccountIDWithCreateNegative = _accountService.GetAccountIdWithCreate(Account.Constants.DONOR, startingBalance.DonorID); ;

            int repositoryProjectCodeGetProjectCodeIdWIthCreateProjectCodeID = _projectCodeService.GetProjectCodeIdWIthCreate(startingBalance.ProjectNumber).ProjectCodeID; ;
            int repositoryShippingInstructionGetSINumberIdWithCreateShippingInstructionID = _shippingInstructionService.GetSINumberIdWithCreate(startingBalance.SINumber).ShippingInstructionID; ;
            int repositoryAccountGetAccountIDWithCreatePosetive = _accountService.GetAccountIdWithCreate(Account.Constants.HUB, user.DefaultHub.Value); ;

            TransactionGroup transactionGroup = new TransactionGroup();

            Transaction transactionOne = new Transaction();

            var transactionGroupId = Guid.NewGuid();

            transactionOne.TransactionID = Guid.NewGuid();
            transactionOne.TransactionGroupID = transactionGroupId;
            transactionOne.PartitionId = 0;
            transactionOne.LedgerID = Cats.Models.Ledger.Constants.GOODS_UNDER_CARE;
            transactionOne.HubOwnerID = user.DefaultHubObj.HubOwner.HubOwnerID;
            transactionOne.AccountID = repositoryAccountGetAccountIDWithCreateNegative;
            transactionOne.HubID = user.DefaultHub.Value;
            transactionOne.StoreID = startingBalance.StoreID;
            transactionOne.Stack = startingBalance.StackNumber;
            transactionOne.ProjectCodeID = repositoryProjectCodeGetProjectCodeIdWIthCreateProjectCodeID;
            transactionOne.ShippingInstructionID = repositoryShippingInstructionGetSINumberIdWithCreateShippingInstructionID;
            transactionOne.ProgramID = startingBalance.ProgramID;
            var comm = _unitOfWork.CommodityRepository.FindById(startingBalance.CommodityID);

            transactionOne.CommodityID = (comm.ParentID != null)
                                                      ? comm.ParentID.Value
                                                      : comm.CommodityID;

            //transactionOne.ParentCommodityID = (comm.ParentID != null)
            //                                           ? comm.ParentID.Value
            //                                           : comm.CommodityID;
            transactionOne.CommodityChildID = startingBalance.CommodityID;
            transactionOne.CommodityGradeID = null;
            transactionOne.QuantityInMT = 0 - startingBalance.QuantityInMT;
            transactionOne.QuantityInUnit = 0 - startingBalance.QuantityInUnit;
            transactionOne.UnitID = startingBalance.UnitID;
            transactionOne.TransactionDate = DateTime.Now;

            Transaction transactionTwo = new Transaction();

            transactionTwo.TransactionID = Guid.NewGuid();
            transactionTwo.TransactionGroupID = transactionGroupId;
            transactionTwo.PartitionId = 0;
            transactionTwo.LedgerID = Cats.Models.Ledger.Constants.GOODS_ON_HAND;
            transactionTwo.HubOwnerID = user.DefaultHubObj.HubOwnerID;
            transactionTwo.AccountID = repositoryAccountGetAccountIDWithCreatePosetive;
            transactionTwo.HubID = user.DefaultHub.Value;
            transactionTwo.StoreID = startingBalance.StoreID;
            transactionTwo.Stack = startingBalance.StackNumber;
            transactionTwo.ProjectCodeID = repositoryProjectCodeGetProjectCodeIdWIthCreateProjectCodeID;
            transactionTwo.ShippingInstructionID = repositoryShippingInstructionGetSINumberIdWithCreateShippingInstructionID;
            transactionTwo.ProgramID = startingBalance.ProgramID;

            transactionTwo.CommodityID = (comm.ParentID != null)
                                                      ? comm.ParentID.Value
                                                      : comm.CommodityID;

            //transactionTwo.ParentCommodityID = (comm.ParentID != null)
            //                                           ? comm.ParentID.Value
            //                                           : comm.CommodityID;
            transactionTwo.CommodityChildID = startingBalance.CommodityID;
            transactionTwo.CommodityGradeID = null; // How did I get this value ?
            transactionTwo.QuantityInMT = startingBalance.QuantityInMT;
            transactionTwo.QuantityInUnit = startingBalance.QuantityInUnit;
            transactionTwo.UnitID = startingBalance.UnitID;
            transactionTwo.TransactionDate = DateTime.Now;

            transactionGroup.PartitionId = 0;

            try
            {
                transactionGroup.TransactionGroupID = transactionGroupId;
                transactionGroup.Transactions.Add(transactionOne);
                transactionGroup.Transactions.Add(transactionTwo);
                _unitOfWork.TransactionGroupRepository.Add(transactionGroup);
                _unitOfWork.Save();

            }
            catch (Exception exp)
            {

                //TODO: Save the detail of this exception somewhere
                throw new Exception("The Starting Balance Transaction Cannot be saved. <br />Detail Message :" + exp.Message);
            }
        }
Example #18
0
 public void populateLookups(UserProfile user)
 {
     ViewBag.FilterCommodityTypeID = new SelectList(_commodityTypeService.GetAllCommodityType(), "CommodityTypeID", "Name");
     ViewBag.HubsID = new SelectList(_hubService.GetAllHub(), "HubID", "HubNameWithOwner", user.DefaultHub.Value);
     ViewBag.RegionCollection = _adminUnitService.FindBy(t => t.AdminUnitTypeID == 2);
 }
Example #19
0
 //TODO remove this function later
 private void InsertDispatch(DispatchModel dispatchModel, UserProfile user)
 {
     List<DispatchDetailModel> commodities = GetSelectedCommodities(dispatchModel.JSONInsertedCommodities);
     dispatchModel.DispatchDetails = commodities;
     _transactionService.SaveDispatchTransaction(dispatchModel,user);
 }
 public List<OtherDispatchAllocation> GetAllToCurrentOwnerHubs(UserProfile user)
 {
     return (from v in _unitOfWork.OtherDispatchAllocationRepository.Get()
             where v.HubID == user.DefaultHub.HubID && v.Hub1.HubOwnerID == user.DefaultHub.HubOwnerID
             select v
            ).OrderByDescending(o => o.AgreementDate).ToList();
 }
Example #21
0
 public void AddNewInternalMovement(InternalMovementViewModel viewModel, UserProfile user)
 {
     //  _unitOfWork.TransactionRepository.SaveInternalMovementTrasnsaction(viewModel, user);
 }
 /// <summary>
 /// Commits the dispatch allocation.
 /// </summary>
 /// <param name="checkedRecords">The checked records.</param>
 /// <param name="SINumber">The SI number.</param>
 /// <param name="user">The user.</param>
 /// <param name="ProjectCode">The project code.</param>
 public void CommitDispatchAllocation(string[] checkedRecords, int SINumber, UserProfile user, int ProjectCode)
 {
     foreach (var checkedRecord in checkedRecords)
     {
         CommitDispatchAllocation(Guid.Parse(checkedRecord), SINumber, ProjectCode);
     }
 }
Example #23
0
        public override MembershipUser CreateUser(string username, string password, string email,
                                                  string passwordQuestion, string passwordAnswer, bool isApproved,
                                                  object providerUserKey, out MembershipCreateStatus status)
        {
            var user = new UserProfile();
            user.ActiveInd = true;
            user.UserName = username;
            user.Email = email;
            user.Password = MD5Hashing.MD5Hash(password);
            user.FirstName = " ";
            user.LastName = " ";
            user.LockedInInd = false;
            user.LanguageCode = "en";
            user.DefaultTheme = "vista";
            user.DatePreference = "en";
            user.PreferedWeightMeasurment = "MT";

            try
            {
                //TODO:More refactoring required
                var userProfileService =
                     (IUserProfileService)DependencyResolver.Current.GetService(typeof(IUserProfileService));
                userProfileService.AddUserProfile(user);
                status = MembershipCreateStatus.Success;
                return GetMembershipUser(user);
            }
            catch (Exception e)
            {
                status = MembershipCreateStatus.ProviderError;
            }

            return null;
        }
Example #24
0
 public void AddNewLossAndAdjustment(LossesAndAdjustmentsViewModel viewModel, UserProfile user)
 {
     _transactionService.SaveLossAdjustmentTransaction(viewModel, user);
 }
Example #25
0
 public bool EditUserProfile(UserProfile entity)
 {
     _unitOfWork.UserProfileRepository.Edit(entity);
     _unitOfWork.Save();
     return true;
 }
Example #26
0
        /// <summary>
        /// </summary>
        /// <param name="viewModel"></param>
        /// <param name="user"></param>
        /// <exception cref="System.Exception"></exception>
        public void SaveInternalMovementTrasnsaction(InternalMovementViewModel viewModel, UserProfile user)
        {
            InternalMovement internalMovement = new InternalMovement();
            TransactionGroup transactionGroup = new TransactionGroup();
            Transaction transactionFromStore = new Transaction();
            var transactionGroupId = Guid.NewGuid();

            Commodity commodity = _unitOfWork.CommodityRepository.FindById(viewModel.CommodityId);

            transactionFromStore.TransactionID = Guid.NewGuid();
            transactionFromStore.TransactionGroupID = transactionGroupId;
            transactionFromStore.LedgerID = 2;
            transactionFromStore.HubOwnerID = user.DefaultHubObj.HubOwner.HubOwnerID;
            //trasaction.AccountID
            transactionFromStore.AccountID = _accountService.GetAccountIdWithCreate(Account.Constants.HUB, user.DefaultHub.Value); //
            transactionFromStore.HubID = user.DefaultHub.Value;
            transactionFromStore.StoreID = viewModel.FromStoreId;  //
            transactionFromStore.Stack = viewModel.FromStackId; //
            transactionFromStore.ProjectCodeID = viewModel.ProjectCodeId;
            transactionFromStore.ShippingInstructionID = viewModel.ShippingInstructionId;
            transactionFromStore.ProgramID = viewModel.ProgramId;
            transactionFromStore.ParentCommodityID = (commodity.ParentID == null)
                                                       ? commodity.CommodityID
                                                       : commodity.ParentID.Value;
            transactionFromStore.CommodityID = viewModel.CommodityId;
            transactionFromStore.CommodityGradeID = null; // How did I get this value ?
            transactionFromStore.QuantityInMT = 0 - viewModel.QuantityInMt;
            transactionFromStore.QuantityInUnit = 0 - viewModel.QuantityInUnit;
            transactionFromStore.UnitID = viewModel.UnitId;
            transactionFromStore.TransactionDate = DateTime.Now;

            Transaction transactionToStore = new Transaction();

            transactionToStore.TransactionID = Guid.NewGuid();
            transactionToStore.TransactionGroupID = transactionGroupId;
            transactionToStore.LedgerID = 2;
            transactionToStore.HubOwnerID = user.DefaultHubObj.HubOwner.HubOwnerID;
            //transactionToStore.AccountID
            transactionToStore.AccountID = _accountService.GetAccountIdWithCreate(Account.Constants.HUB, user.DefaultHub.Value); //
            transactionToStore.HubID = user.DefaultHub.Value;
            transactionToStore.StoreID = viewModel.ToStoreId;  //
            transactionToStore.Stack = viewModel.ToStackId; //
            transactionToStore.ProjectCodeID = viewModel.ProjectCodeId;
            transactionToStore.ShippingInstructionID = viewModel.ShippingInstructionId;
            transactionToStore.ProgramID = viewModel.ProgramId;

            transactionToStore.ParentCommodityID = (commodity.ParentID == null)
                                                       ? commodity.CommodityID
                                                       : commodity.ParentID.Value;
            transactionToStore.CommodityID = viewModel.CommodityId;
            transactionToStore.CommodityGradeID = null; // How did I get this value ?
            transactionToStore.QuantityInMT = viewModel.QuantityInMt;
            transactionToStore.QuantityInUnit = viewModel.QuantityInUnit;
            transactionToStore.UnitID = viewModel.UnitId;
            transactionToStore.TransactionDate = DateTime.Now;

            transactionGroup.TransactionGroupID = transactionGroupId;
            transactionGroup.Transactions.Add(transactionFromStore);
            transactionGroup.Transactions.Add(transactionToStore);
            transactionGroup.PartitionId = 0;

            internalMovement.InternalMovementID = Guid.NewGuid();
            internalMovement.PartitionId = 0;
            internalMovement.TransactionGroupID = transactionGroupId;
            internalMovement.TransactionGroup = transactionGroup;
            internalMovement.TransferDate = viewModel.SelectedDate;
            internalMovement.DReason = viewModel.ReasonId;
            internalMovement.Notes = viewModel.Note;
            internalMovement.ApprovedBy = viewModel.ApprovedBy;
            internalMovement.ReferenceNumber = viewModel.ReferenceNumber;
            internalMovement.HubID = user.DefaultHub.Value;

            // Try to save this transaction

            try
            {
                _unitOfWork.InternalMovementRepository.Add(internalMovement);
                _unitOfWork.Save();
            }
            catch (Exception exp)
            {
                //dbTransaction.Rollback();
                //TODO: Save the detail of this exception somewhere
                throw new Exception("The Internal Movement Transaction Cannot be saved. <br />Detail Message :" + exp.Message);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ReceiptAllocationViewModel"/> class.
 /// </summary>
 /// <param name="unitOfWork">The unit of work.</param>
 /// <param name="userProfile">The user profile.</param>
 public ReceiptAllocationViewModel(List<Commodity> commodities, List<Donor> donors, List<Hub> allHubs, List<Program> programs, List<CommoditySource> commoditySources, List<CommodityType> commodityTypes, UserProfile user, List<Receive> receiveList)
 {
     //_Repository = unitOfWork;
     _UserProfile = user;
     InitalizeViewModel(commodities, donors, allHubs, programs, commoditySources, commodityTypes,  receiveList);
 }
Example #28
0
        public void SaveAdjustment(StockAdjustmentViewModel viewModel, UserProfile user,int stockType)
        {
            Commodity commodity = _unitOfWork.CommodityRepository.FindById((int)viewModel.CommodityID);
            int ledgerPlus, LedgerMinus;
            if (stockType == 0)
            {
                LedgerMinus = Cats.Models.Ledger.Constants.GOODS_ON_HAND;
                ledgerPlus = Cats.Models.Ledger.Constants.LOSS_IN_TRANSIT;
            }
            else
            {
                LedgerMinus = Cats.Models.Ledger.Constants.COMMITED_TO_FDP;
                ledgerPlus = Cats.Models.Ledger.Constants.PLEDGED_TO_FDP;
            }

            Adjustment lossAndAdjustment = new Adjustment();
            TransactionGroup transactionGroup = new TransactionGroup();
            Transaction transactionOne = new Transaction();

            var transactionGroupId = Guid.NewGuid();

            transactionOne.TransactionID = Guid.NewGuid();
            transactionOne.TransactionGroupID = transactionGroupId;
            transactionOne.LedgerID = LedgerMinus;// 2;
            transactionOne.HubOwnerID = user.DefaultHubObj.HubOwner.HubOwnerID;
            //transactionOne.AccountID = _accountService.GetAccountIdWithCreate(Account.Constants.HUB, user.DefaultHub.Value); //
            transactionOne.HubID = user.DefaultHub.Value;
            transactionOne.StoreID = viewModel.StoreID;  //
            transactionOne.ProjectCodeID = viewModel.ProjectCodeID;
            transactionOne.ShippingInstructionID = viewModel.ShippingInstructionID;

            transactionOne.ParentCommodityID = (commodity.ParentID == null)
                                                       ? commodity.CommodityID
                                                       : commodity.ParentID.Value;
            transactionOne.CommodityID = viewModel.CommodityID;
            transactionOne.ProgramID = viewModel.ProgramID;
            transactionOne.CommodityGradeID = null; // How did I get this value ?

                transactionOne.QuantityInMT = 0-viewModel.QuantityInMT;
                transactionOne.QuantityInUnit =0- viewModel.QuantityInUnit;

            transactionOne.UnitID =1;
            transactionOne.TransactionDate = DateTime.Now;

            Transaction transactionTwo = new Transaction();

            transactionTwo.TransactionID = Guid.NewGuid();
            transactionTwo.TransactionGroupID = transactionGroupId;
            transactionTwo.LedgerID = ledgerPlus;// 14;
            transactionTwo.HubOwnerID = user.DefaultHubObj.HubOwnerID;
            //transactionTwo.AccountID = _accountService.GetAccountIdWithCreate(Account.Constants.HUB, user.DefaultHub.Value); //
            transactionTwo.HubID = user.DefaultHub.Value;
            transactionTwo.StoreID = viewModel.StoreID;  //
            transactionTwo.ProjectCodeID = viewModel.ProjectCodeID;
            transactionTwo.ShippingInstructionID = viewModel.ShippingInstructionID;
            transactionTwo.ParentCommodityID = (commodity.ParentID == null)
                                                       ? commodity.CommodityID
                                                       : commodity.ParentID.Value;
            transactionTwo.CommodityID = viewModel.CommodityID;
            transactionTwo.ProgramID = viewModel.ProgramID;
            transactionTwo.CommodityGradeID = null; // How did I get this value ?

                transactionTwo.QuantityInMT = viewModel.QuantityInMT;
                transactionTwo.QuantityInUnit = viewModel.QuantityInUnit;

            transactionTwo.UnitID =1;
            transactionTwo.TransactionDate = DateTime.Now;

            transactionGroup.TransactionGroupID = transactionGroupId;
            transactionGroup.Transactions.Add(transactionOne);
            transactionGroup.Transactions.Add(transactionTwo);

            lossAndAdjustment.PartitionId = 0;
            lossAndAdjustment.AdjustmentID = Guid.NewGuid();
            lossAndAdjustment.TransactionGroupID = transactionGroupId;
            lossAndAdjustment.TransactionGroup = transactionGroup;
            lossAndAdjustment.HubID = user.DefaultHub.Value;
            lossAndAdjustment.AdjustmentReasonID = 7;
            lossAndAdjustment.AdjustmentDirection = "S";
            lossAndAdjustment.AdjustmentDate = DateTime.Now.Date;
            lossAndAdjustment.ApprovedBy = "";
            lossAndAdjustment.Remarks = "Stock take adjustement";
            lossAndAdjustment.UserProfileID = user.UserProfileID;
            lossAndAdjustment.ReferenceNumber = "";
            lossAndAdjustment.StoreManName = "";

            // Try to save this transaction
            try
            {
                _unitOfWork.AdjustmentRepository.Add(lossAndAdjustment);
                _unitOfWork.Save();
            }
            catch (Exception exp)
            {
                // dbTransaction.Rollback();
                //TODO: Save the detail of this exception somewhere
                throw new Exception("The Internal Movement Transaction Cannot be saved. <br />Detail Message :" + exp.Message);
            }
        }
Example #29
0
 private MembershipUser GetMembershipUser(UserProfile user)
 {
     //Membership membership = user.Membership;
     var mUser = new MembershipUser("MemberProvider", user.UserName, user.UserProfileID, user.Email,
                                    string.Empty, string.Empty, false, false, DateTime.Now, DateTime.Now,
                                    DateTime.Now, DateTime.Now, DateTime.Now);
     return mUser;
 }
Example #30
0
 /// <summary>
 /// Saves the loss adjustment transaction.
 /// </summary>
 /// <param name="viewModel">The view model.</param>
 /// <param name="user">The user.</param>
 public void SaveLossAdjustmentTransaction(LossesAndAdjustmentsViewModel viewModel, UserProfile user)
 {
     if (viewModel.IsLoss == true)
     {
         SaveLossTrasnsaction(viewModel, user);
     }
     else
     {
         SaveAdjustmentTrasnsaction(viewModel, user);
     }
 }