public async Task <object> issuebook([FromBody] object model)
        {
            object result = null; string message = string.Empty;

            try
            {
                if (model == null)
                {
                    return(BadRequest());
                }

                var bookIssued = JsonConvert.DeserializeObject <vmBookIssuereturn>(model.ToString());

                //Save
                _objcirculation = new Circulation();
                message         = await _objcirculation.issuebook(bookIssued);
            }
            catch (Exception ex)
            {
                ex.ToString();
            }

            result = new
            {
                message
            };

            return(result);
        }
예제 #2
0
        // GET: /Circulation/Create/pendingId
        public IActionResult Create(int?id)
        {
            string method = "Circulation/Create";

            Log.Me.Debug(method + " - User: "******", PendingId: " + (id ?? 0).ToString());
            ApplicationVersion();

            if (NullId(id, "PendingId", method))
            {
                return(RedirectToAction("Error", "Home"));
            }

            Circulation circ = new Circulation();

            circ.Id          = 0;
            circ.RecipientID = 0;
            circ.PendingId   = id.Value;
            circ.Name        = "";
            circ.Email       = "";
            circ.Address     = "";

            ViewData["InternalEmailDomain"] = EmailConfig.Me.InternalEmailDomain;

            PendingReport report   = _context.PendingReportRepo.Read(circ.PendingId);
            string        oversize = (report.eFilePath ?? "") == "OVERSIZE" ? "Yes" : "No";

            return(View("Edit", new CirculationViewModel(circ, oversize)));
        }
        public async Task <object> returnbook([FromBody] vmBookIssuereturn model)
        {
            object result = null; string message = string.Empty;

            try
            {
                if (model == null)
                {
                    return(BadRequest());
                }

                //Save
                _objcirculation = new Circulation();
                message         = await _objcirculation.returnbook(model);
            }
            catch (Exception ex)
            {
                ex.ToString();
            }

            result = new
            {
                message
            };

            return(result);
        }
예제 #4
0
        public void Build_SupplyAllParatmeterCorrect_ReturnsValidCirculatinBenefit()
        {
            //Arrange
            var membershipId  = Guid.NewGuid();
            var borrowPeriod  = 15;
            var noOfNrewals   = 2;
            var renewalPeriod = 10;
            var lockingPeriod = 15;

            //Act
            Circulation benefit = (Circulation)CirculationBuilder.Circulation()
                                  .ForCirculationType(CirculationType.Book)
                                  .ForMembershipType(membershipId)
                                  .CirculationsCanBeBorrowedFor(borrowPeriod)
                                  .CanBeRenewed(noOfNrewals)
                                  .EachRenewalIs(renewalPeriod)
                                  .ThenLockedFor(lockingPeriod)
                                  .Build();

            //Assert
            Assert.AreEqual(membershipId, benefit.MembershipTypeId);
            Assert.AreEqual(borrowPeriod, benefit.BorrowPeriod);
            Assert.AreEqual(noOfNrewals, benefit.NumberOfRenewals);
            Assert.AreEqual(lockingPeriod, benefit.LockingPeriod);
            Assert.AreEqual(renewalPeriod, benefit.RenewalPeriod);
        }
예제 #5
0
        public ActionResult Create(Circulation circ)
        {
            string method = "Circulation/Create[Post]";

            if (ZeroId(circ.PendingId, "PendingId", method))
            {
                return(RedirectToAction("Error", "Home"));
            }

            //if (!ModelState.IsValid) return View(new CirculationViewModel(circ));

            try
            {
                _context.CirculationRepo.Create(circ);

                Log.Me.Info(CheckIdentity().UserName + " added circulation to report " + circ.PendingId.ToString());

                return(RedirectToAction("Index", "Circulation", new { id = circ.PendingId }));
            }
            catch (Exception ex)
            {
                Log.Me.Error("Exception in " + method + ": " + ex.Message);
                return(RedirectToAction("Error", "Home"));
            }
        }
예제 #6
0
        public CirculationViewModel(Circulation c, string oversize)
        {
            if (c != null)
            {
                this.Id          = c.Id;
                this.Name        = c.Name;
                this.Email       = c.Email;
                this.Address     = c.Address;
                this.ToCcBccDB   = c.ToCcBccDB;
                this.Delivery    = c.Delivery;
                this.PendingId   = c.PendingId;
                this.RecipientID = c.RecipientID;
                this.State       = c.State;

                this.Oversize = oversize;

                this.ElecDeliveryTypes = new List <SelectListItem>();
                this.ElecDeliveryTypes.Add(new SelectListItem("None", ""));
                this.ElecDeliveryTypes.Add(new SelectListItem("Summary Only", "ES"));
                this.ElecDeliveryTypes.Add(new SelectListItem("Full Report", "EF"));
                this.ElecDeliveryTypes.Add(new SelectListItem("Summary with CD to follow", "EC"));

                this.PaperDeliveryTypes = new List <SelectListItem>();
                this.PaperDeliveryTypes.Add(new SelectListItem("None", ""));
                this.PaperDeliveryTypes.Add(new SelectListItem("Summary Only", "PS"));
                this.PaperDeliveryTypes.Add(new SelectListItem("Full Report", "PF"));
            }
        }
예제 #7
0
        // GET: /Circulation/Edit/n
        public IActionResult Edit(int?id)
        {
            string method = "Circulation/Edit";

            Log.Me.Debug(method + " - User: "******", CirculationId: " + (id ?? 0).ToString());
            ApplicationVersion();

            if (NullId(id, "CirculationId", method))
            {
                return(RedirectToAction("Error", "Home"));
            }

            try
            {
                Circulation circ = null;
                if ((circ = Read(id.Value, method)) == null)
                {
                    return(RedirectToAction("Error", "Home"));
                }

                PendingReport report   = _context.PendingReportRepo.Read(circ.PendingId);
                string        oversize = (report.eFilePath ?? "") == "OVERSIZE" ? "Yes" : "No";

                ViewData["InternalEmailDomain"] = EmailConfig.Me.InternalEmailDomain;

                return(View(new CirculationViewModel(circ, oversize)));
            }
            catch (Exception ex)
            {
                Log.Me.Error("Exception in " + method + ": " + ex.Message);
                return(RedirectToAction("Error", "Home"));
            }
        }
예제 #8
0
        // GET: /Circulation/Delete/n
        public IActionResult Delete(int?id)
        {
            string method = "Circulation/Delete";

            if (NullId(id, "CirculationId", method))
            {
                return(RedirectToAction("Error", "Home"));
            }

            try
            {
                Circulation circ = null;
                if ((circ = Read(id.Value, method)) == null)
                {
                    return(RedirectToAction("Error", "Home"));
                }

                if (ZeroId(circ.PendingId, "PendingId", method))
                {
                    return(RedirectToAction("Error", "Home"));
                }

                _context.CirculationRepo.Delete(id);

                Log.Me.Info(CheckIdentity().UserName + " deleted circulation from report " + circ.PendingId.ToString());

                return(RedirectToAction("Index", "Circulation", new { id = circ.PendingId }));
            }
            catch (Exception ex)
            {
                Log.Me.Error("Exception in " + method + ": " + ex.Message);
                return(RedirectToAction("Error", "Home"));
            }
        }
        public void TestMethod1()
        {
            //Arrange
            var membershipId  = Guid.NewGuid();
            var borrowPeriod  = 15;
            var noOfNrewals   = 2;
            var renewalPeriod = 10;
            var lockingPeriod = 15;

            //Act
            Circulation benefit = (Circulation)CirculationBuilder.Circulation()
                                  .ForCirculationType(CirculationType.Book)
                                  .ForMembershipType(membershipId)
                                  .CirculationsCanBeBorrowedFor(borrowPeriod)
                                  .CanBeRenewed(noOfNrewals)
                                  .EachRenewalIs(renewalPeriod)
                                  .ThenLockedFor(lockingPeriod)
                                  .Build();

            Circulation benefit2 = (Circulation)CirculationBuilder.Circulation()
                                   .ForCirculationType(CirculationType.Book)
                                   .ForMembershipType(membershipId)
                                   .CirculationsCanBeBorrowedFor(borrowPeriod)
                                   .CanBeRenewed(noOfNrewals)
                                   .EachRenewalIs(renewalPeriod)
                                   .ThenLockedFor(lockingPeriod)
                                   .Build();


            var category = MembershipCategory.Create("Category1", "Description", benefit, benefit2);

            category.IsValid();
        }
예제 #10
0
 /// <summary>
 /// Initializes all config classes
 /// </summary>
 public Config()
 {
     map           = new Map();
     elevation     = new Elevation();
     temperature   = new Temperature();
     precipitation = new Precipitation();
     humidity      = new Humidity();
     circulation   = new Circulation();
 }
예제 #11
0
        public ActionResult Edit(Circulation cr)
        {
            ctx.Entry <Circulation>(cr).State = System.Data.Entity.EntityState.Modified;

            ctx.SaveChanges();

            TempData["Message"] = "گردش با موفقیت ویرایش شد";
            return(RedirectToAction("CirculationsHome", "AddCirculations"));
        }
예제 #12
0
        public Circulation Read(int id, string method)
        {
            Circulation circ = _context.CirculationRepo.Read(id);

            if (circ == null)
            {
                Log.Me.Fatal("Circulation with id " + id.ToString() + " could not be read in " + method);
            }
            return(circ);
        }
예제 #13
0
        public ActionResult addRevenue(int weight, int amount)
        {
            var tem_AID = Request.Cookies["AID"].Value;
            var checkA  = db.Farms.Where(a => a.AID.Equals(tem_AID)).FirstOrDefault();
            int FID     = Convert.ToInt32(checkA.FID);
            var invest  = checkA.Invest;
            var checkC  = db.Circulations.Where(a => a.FID == (FID) && a.Invest == (invest)).FirstOrDefault <Circulation>();

            Revenue revenue = new Revenue();

            revenue.Weight = weight;
            revenue.amount = amount;
            revenue.R_date = Request.Form["date"];
            revenue.R_list = Request.Form["list"];
            revenue.Shop   = Request.Form["shop"];
            revenue.payee  = Request.Form["payee"];



            if (ModelState.IsValid)
            {
                if ((checkC != null))
                {
                    var amount_c = checkC.Circulation1;
                    var CID      = checkC.CID;
                    if (CID != null)
                    {
                        var checkupdate = db.Circulations.Where(a => a.CID.Equals(CID)).FirstOrDefault();
                        checkupdate.Circulation1 = amount_c + amount;
                        db.SaveChanges();
                        revenue.CID = checkC.CID;
                    }
                }
                else if ((checkC == null))
                {
                    Circulation circulation = new Circulation();
                    circulation.Invest       = invest;
                    circulation.Circulation1 = amount;
                    circulation.FID          = FID;

                    db.Circulations.Add(circulation);
                    db.SaveChanges();
                    var check = db.Circulations.Where(a => a.Invest == (invest) && a.FID == (FID)).FirstOrDefault();
                    revenue.CID = check.CID;
                    db.SaveChanges();
                }

                db.Revenues.Add(revenue);
                db.SaveChanges();
                ViewBag.Message = "บันทึกสำเร็จ";
            }

            return(View());
        }
예제 #14
0
        public async Task <IActionResult> AddCirculation([FromBody] Circulation circulation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            repository.AddCirculation(circulation);
            await unitOfWork.CompleteAsync();

            return(Ok(circulation));
        }
예제 #15
0
        public ActionResult addExpenditure(int amount)
        {
            var tem_AID  = Request.Cookies["AID"].Value;
            var checkA   = db.Farms.Where(a => a.AID.Equals(tem_AID)).FirstOrDefault();
            int FID      = Convert.ToInt32(checkA.FID);
            var invest   = checkA.Invest;
            var checkC   = db.Circulations.Where(a => a.FID == (FID) && a.Invest == (invest)).FirstOrDefault <Circulation>();
            var CID      = checkC.CID;
            var amount_c = checkC.Circulation1;

            Expenditure expenditure = new Expenditure();

            expenditure.amount = amount;
            expenditure.E_date = Request.Form["date"];
            expenditure.E_list = Request.Form["list"];
            expenditure.payor  = Request.Form["payor"];
            expenditure.note   = Request.Form["note"];



            if (ModelState.IsValid)
            {
                if ((checkC != null))
                {
                    if (CID != null)
                    {
                        var checkupdate = db.Circulations.Where(a => a.CID.Equals(CID)).FirstOrDefault();
                        checkupdate.Circulation1 = amount_c - amount;
                        db.SaveChanges();
                        expenditure.CID = checkC.CID;
                    }
                }
                else if ((checkC == null))
                {
                    Circulation circulation = new Circulation();
                    circulation.Invest       = invest;
                    circulation.Circulation1 = -amount;
                    circulation.FID          = FID;


                    db.Circulations.Add(circulation);
                    db.SaveChanges();
                    var check = db.Circulations.Where(a => a.Invest == (invest) && a.FID == (FID)).FirstOrDefault();
                    expenditure.CID = check.CID;
                    db.SaveChanges();
                }
                db.Expenditures.Add(expenditure);
                db.SaveChanges();
                ViewBag.Message = "บันทึกสำเร็จ";
            }

            return(View());
        }
예제 #16
0
        // GET: /Circulation/Add?pendingId=x&recipientId=y
        public IActionResult Add(int?recipientId, int?pendingId)
        {
            string method = "Circulation/Add";

            if (NullId(recipientId, "RecipientId", method))
            {
                return(RedirectToAction("Error", "Home"));
            }
            if (NullId(pendingId, "PendingId", method))
            {
                return(RedirectToAction("Error", "Home"));
            }

            Recipient r = _context.RecipientRepo.Read(recipientId);

            if (r == null)
            {
                Log.Me.Fatal("Recipient with id " + recipientId.ToString() + " could not be read in Circulation/Add");
                return(RedirectToAction("Error", "Home"));
            }

            try
            {
                Circulation circ = new Circulation();
                circ.Id          = 0;
                circ.RecipientID = recipientId;
                circ.PendingId   = pendingId ?? 0;
                circ.Name        = r.Name;
                circ.Email       = r.Email;
                circ.Address     = r.Address;
                //int? circId = _context.CirculationRepo.Create(circ);

                //Log.Me.Info(CheckIdentity().UserName + " added circulation to report " + circ.PendingId.ToString());

                //return RedirectToAction("Edit", "Circulation", new { id = circId });

                PendingReport report   = _context.PendingReportRepo.Read(circ.PendingId);
                string        oversize = (report.eFilePath ?? "") == "OVERSIZE" ? "Yes" : "No";

                ViewData["InternalEmailDomain"] = EmailConfig.Me.InternalEmailDomain;

                return(View("Edit", new CirculationViewModel(circ, oversize)));
            }
            catch (Exception ex)
            {
                Log.Me.Error("Exception in " + method + ": " + ex.Message);
                return(RedirectToAction("Error", "Home"));
            }
        }
        public async Task <List <vmBookIssuereturn> > getissueall()
        {
            List <vmBookIssuereturn> bookIssueissue = null;

            try
            {
                _objcirculation = new Circulation();
                bookIssueissue  = await _objcirculation.getissueall();
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            return(bookIssueissue);
        }
        public async Task <List <vmBook> > getallbook()
        {
            List <vmBook> books = null;

            try
            {
                _objcirculation = new Circulation();
                books           = await _objcirculation.getallbook();
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            return(books);
        }
        public async Task <vmBookIssuereturn> getreturnbyid(int id)
        {
            vmBookIssuereturn bookIssuereturn = null;

            try
            {
                _objcirculation = new Circulation();
                bookIssuereturn = await _objcirculation.getreturnbyid(id);
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            return(bookIssuereturn);
        }
예제 #20
0
        public ActionResult Cancel(Circulation update)
        {
            string method = "Circulation/Cancel";

            if (IsNull(update, "Circulation", method))
            {
                return(RedirectToAction("Error", "Home"));
            }
            if (ZeroId(update.PendingId, "PendingId", method))
            {
                return(RedirectToAction("Error", "Home"));
            }

            return(RedirectToAction("Index", "Circulation", new { id = update.PendingId }));
        }
예제 #21
0
        public void Build_NothingAssigned_ThrowInvalidBenefitException()
        {
            //Arrange
            var membershipId  = Guid.NewGuid();
            var borrowPeriod  = 15;
            var noOfNrewals   = 2;
            var renewalPeriod = 10;
            var lockingPeriod = 15;

            //Act
            var         builder = BenefitBuilderFactory.CreateBenefitBuilder(BenefitType.Circulation) as CirculationBuilder;
            Circulation benefit = builder
                                  .ForCirculationType(CirculationType.Book)
                                  .Build() as Circulation;
            //Assert
        }
예제 #22
0
        public ActionResult Edit(Circulation update)
        {
            string method = "Circulation/Edit[Post]";

            if (IsNull(update, "Circulation", method))
            {
                return(RedirectToAction("Error", "Home"));
            }
            if (NullId(update.Id, "CirculationId", method))
            {
                return(RedirectToAction("Error", "Home"));
            }

            //if (!ModelState.IsValid) return View(new CirculationViewModel(update));

            try
            {
                Circulation circ = null;
                if ((circ = Read(update.Id, method)) == null)
                {
                    return(RedirectToAction("Error", "Home"));
                }
                if (ZeroId(circ.PendingId, "PendingId", method))
                {
                    return(RedirectToAction("Error", "Home"));
                }

                circ.Name     = update.Name;
                circ.Email    = update.Email;
                circ.Address  = update.Address;
                circ.ToCcBcc  = update.ToCcBcc;
                circ.Delivery = update.Delivery;
                _context.CirculationRepo.Update(circ);

                Log.Me.Info(CheckIdentity().UserName + " updated circulation on report " + circ.PendingId.ToString());

                return(RedirectToAction("Index", "Circulation", new { id = circ.PendingId }));
            }
            catch (Exception ex)
            {
                Log.Me.Error("Exception in " + method + ": " + ex.Message);
                return(RedirectToAction("Error", "Home"));
            }
        }
예제 #23
0
        public void Build_CirculationPeriodIsZero_ThrowInvalidBenefitException()
        {
            //Arrange
            var membershipId  = Guid.NewGuid();
            var borrowPeriod  = 15;
            var noOfNrewals   = 2;
            var renewalPeriod = 10;
            var lockingPeriod = 15;

            //Act
            Circulation benefit = (Circulation)CirculationBuilder.Circulation()
                                  .ForMembershipType(membershipId)
                                  //.CirculationsCanBeBorrowedFor(borrowPeriod)
                                  .CanBeRenewed(noOfNrewals)
                                  .EachRenewalIs(renewalPeriod)
                                  .ThenLockedFor(lockingPeriod)
                                  .Build();
            //Assert
        }
예제 #24
0
 /// <inheritdoc cref="object.ToString" />
 public override string ToString()
 {
     return(string.Format
            (
                "Number: {0}, Name: {1}, Password: {2}, "
                + "Cataloger: {3}, Reader: {4}, Circulation: {5}, "
                + "Acquisitions: {6}, Provision: {7}, "
                + "Administrator: {8}",
                Number.ToVisibleString(),
                Name.ToVisibleString(),
                Password.ToVisibleString(),
                Cataloger.ToVisibleString(),
                Reader.ToVisibleString(),
                Circulation.ToVisibleString(),
                Acquisitions.ToVisibleString(),
                Provision.ToVisibleString(),
                Administrator.ToVisibleString()
            ));
 }
예제 #25
0
        public ActionResult Index(AddCirculationViewModels circulate)
        {
            if (ModelState.IsValid)
            {
                var c = new Circulation()
                {
                    MemberId    = circulate.MemberId,
                    Issue_Date  = circulate.Issue_Date,
                    Day_Number  = circulate.Day_Number,
                    BookId      = circulate.BookId,
                    Expire_Date = circulate.Issue_Date.AddDays(circulate.Day_Number)
                };

                ctx.Circulations.Add(c);
                ctx.SaveChanges();
                TempData["Message"] = "گردش مورد نظر با موفقیت اضافه شد";
                return(RedirectToAction("Index"));
            }
            TempData["Message"] = "اطلاعات وارد شده صحیح نمی باشد";
            return(View());
        }
예제 #26
0
 static bool CheckCirculation(Circulation c, Circulation testdata)
 {
     return(c.Name == testdata.Name && c.Email == testdata.Email && c.ToCcBcc == testdata.ToCcBcc && c.Delivery == testdata.Delivery);
 }
예제 #27
0
 public Circulation GetBookCirculation(int accountid, int bookid)
 {
     Circulation book = new Circulation();
     SqlCommand com = new SqlCommand("SELECT * FROM tblBookCirculation WHERE AccountID=@AccountID AND BookID = @BookID", con);
     com.Parameters.Add("@AccountID", SqlDbType.Int).Value = accountid;
     com.Parameters.Add("@BookID", SqlDbType.Int).Value = bookid;
     SqlDataReader sdr = com.ExecuteReader();
     while (sdr.Read())
     {
         book.BookCirculationID = Convert.ToInt32(sdr["BookCirculationID"]);
         book.AccountID = Convert.ToInt32(sdr["AccountID"]);
         book.BookID = Convert.ToInt32(sdr["BookID"].ToString());
         book.BorrowedOn = sdr["BorrowedOn"].ToString();
         book.ReturnedOn = sdr["ReturnedOn"].ToString();
         book.DateDue = sdr["DateDue"].ToString();
         book.LendBy = sdr["LendBy"].ToString();
         book.BorrowedBy = sdr["BorrowedBy"].ToString();
         book.ReceivedBy = sdr["ReceivedBy"].ToString();
         book.CirculationStatus = sdr["CirculationStatus"].ToString();
         book.CiculationType = sdr["CirculationType"].ToString();
     }
     return book;
 }
예제 #28
0
    public Circulation GetMultimediaCirculation(int accountid, int multimediaid)
    {
        con.Open();
        Circulation multimedia = new Circulation();
        SqlCommand com = new SqlCommand("SELECT * FROM tblMultimediaCirculation WHERE AccountID=@AccountID AND MultimediaID = @MultimediaCirculationID", con);
        com.Parameters.Add("@AccountID", SqlDbType.Int).Value = accountid;
        com.Parameters.Add("@MultimediaCirculationID", SqlDbType.Int).Value = multimediaid;
        SqlDataReader sdr = com.ExecuteReader();
        while (sdr.Read())
        {
            multimedia.MultimediaCirculationID = Convert.ToInt32(sdr["MultimediaCirculationID"].ToString());
            multimedia.AccountID = Convert.ToInt32(sdr["AccountID"].ToString());
            multimedia.MultimediaID = Convert.ToInt32(sdr["MultimediaID"].ToString());
            multimedia.ReturnedOn = sdr["ReturnedOn"].ToString();
            multimedia.DateDue = sdr["DateDue"].ToString();
            multimedia.LendBy = sdr["LendBy"].ToString();
            multimedia.BorrowedBy = sdr["BorrowedBy"].ToString();
            multimedia.ReceivedBy = sdr["ReceivedBy"].ToString();
            multimedia.CirculationStatus = sdr["CirculationStatus"].ToString();
            multimedia.CiculationType = sdr["CirculationType"].ToString();
        }

        con.Close();
        return multimedia;
    }
예제 #29
0
 public void AddCirculation(Circulation circulation)
 {
     context.Circulations.Add(circulation);
 }