Example #1
0
        public JsonResult SaveCommittee(CommitteeModel model)
        {
            var Message = "Action Failed";

            if (model.Id > 0)
            {
                Committee updateDB = db.Committees.Find(model.Id);
                updateDB.Organization_Id = model.OrganizationId;
                updateDB.Name            = model.Name;
                updateDB.Status          = model.Status;
                updateDB.Duration_Date   = model.Duration_Date;
                db.Entry(updateDB).State = EntityState.Modified;
                db.SaveChanges();
                Message = model.Name + " Updated Successfully";
            }
            else
            {
                Committee committeeDB = new Committee();
                committeeDB.Organization_Id = model.OrganizationId;
                committeeDB.Name            = model.Name;
                committeeDB.Created_Date    = DateTime.Now;
                committeeDB.Duration_Date   = model.Duration_Date;
                committeeDB.Status          = model.Status;
                db.Committees.Add(committeeDB);
                db.SaveChanges();
                Message = model.Name + " Added Successfully";
            }
            return(Json(new { Message = Message }, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public async Task <ActionResult> AddToCommittee([Bind(Include = "ConsumerRepCommitteeHistoryModelID,CommitteeModelID,ConsumerRepModelID,PrepTime,Meetingtime,EndorsementStatus,EndorsementDate,EndorsementType")] ConsumerRepCommitteeHistoryModel consumerrepcommitteehistorymodel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    consumerrepcommitteehistorymodel.ReportedDate = DateTime.Today;

                    CommitteeModel committee = db.Committees.Find(consumerrepcommitteehistorymodel.CommitteeModelID);
                    committee.CurrentStatus   = CurrentStatus.Current;
                    db.Entry(committee).State = EntityState.Modified;

                    ConsumerRepModel consumer = db.ConsumerReps.Find(consumerrepcommitteehistorymodel.ConsumerRepModelID);
                    consumer.EndorsementStatus = EndorsementStatus.Active;
                    db.Entry(consumer).State   = EntityState.Modified;

                    db.ConsumerRepCommitteeHistory.Add(consumerrepcommitteehistorymodel);

                    await db.SaveChangesAsync();

                    return(RedirectToAction("Details/" + consumerrepcommitteehistorymodel.ConsumerRepModelID, "ConsumerRepModel"));
                }
            }
            catch (DataException /* dex */)
            {
                // Log the error
                ModelState.AddModelError("", "Unable to save changes. Please Try Again.");
            }

            ViewBag.CommitteeModelID   = new SelectList(db.Committees, "CommitteeModelID", "CommitteeName");
            ViewBag.ConsumerRepModelID = consumerrepcommitteehistorymodel.ConsumerRepModelID;
            return(View());
        }
        public async Task <ActionResult> SetInActive(int id)
        {
            try
            {
                CommitteeModel committeemodel = await db.Committees.FindAsync(id);

                committeemodel.CurrentStatus   = CurrentStatus.Past;
                db.Entry(committeemodel).State = EntityState.Modified;

                var committeehistory = from comHistory in db.ConsumerRepCommitteeHistory
                                       where comHistory.CommitteeModelID == committeemodel.CommitteeModelID
                                       select comHistory;


                foreach (var comHistory in committeehistory)
                {
                    comHistory.FinishedDate    = DateTime.Today;
                    db.Entry(comHistory).State = EntityState.Modified;

                    ConsumerRepModel consumerRep = db.ConsumerReps.Find(comHistory.ConsumerRepModelID);
                    consumerRep.EndorsementStatus = EndorsementStatus.InActive;
                    db.Entry(consumerRep).State   = EntityState.Modified;
                }

                await db.SaveChangesAsync();
            }
            catch (DataException /* dex */)
            {
                return(RedirectToAction("SetInActive", new { id = id, saveChancesError = true }));
            }
            return(RedirectToAction("Index"));
        }
Example #4
0
        public async Task <CommitteeModel> Update([FromBody] CommitteeModel committeeModel)
        {
            committeeModel.AgencyCode = User.UserAgency();
            var committeeResult = await _committeeApplication.UpdateAsync(committeeModel);

            committeeModel = _mapper.Map <CommitteeModel>(committeeResult);
            return(committeeModel);
        }
Example #5
0
        public async Task <CommitteeModel> Post([FromBody] CommitteeModel committeeModel)
        {
            var committeeObject = _mapper.Map <Committee>(committeeModel);
            var committeeResult = await _committeeApplication.CreateAsync(committeeObject);

            committeeModel = _mapper.Map <CommitteeModel>(committeeResult);
            return(committeeModel);
        }
Example #6
0
        public PartialViewResult CommitteeInformations2(int ID)
        {
            CommitteeModel Obj = new CommitteeModel();

            Obj.Committee = OCPB.GetCompany.CompanyMethod.Get.GetCompany_CommitteeInformations(ID);
            Obj.Authorize = OCPB.GetCompany.CompanyMethod.Get.GetCompany_AuthorizeDescriptions(ID);
            return(PartialView("View/Committee2", Obj));
        }
Example #7
0
        public async Task <Committee> UpdateAsync(CommitteeModel committeeModel)
        {
            Check.ArgumentNotNull(nameof(committeeModel), committeeModel);
            await _committeeDomainService.CheckNameExist(committeeModel.CommitteeName, committeeModel.AgencyCode, committeeModel.CommitteeId);

            var committee = await _committeeQueries.GetById(committeeModel.CommitteeId);

            committee.Update(committeeModel.CommitteeName, committeeModel.Address, committeeModel.Phone, committeeModel.Fax, committeeModel.Email, committeeModel.PostalCode, committeeModel.ZipCode);
            var result = _genericCommandRepository.Update(committee);
            await _genericCommandRepository.SaveAsync();

            return(result);
        }
        // GET: /CommitteeModel/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CommitteeModel committeemodel = await db.Committees.FindAsync(id);

            if (committeemodel == null)
            {
                return(HttpNotFound());
            }
            return(View(committeemodel));
        }
        public async Task <ActionResult> Delete(int id)
        {
            try
            {
                CommitteeModel committeemodel = await db.Committees.FindAsync(id);

                db.Committees.Remove(committeemodel);
                await db.SaveChangesAsync();
            }
            catch (DataException /* dex */)
            {
                return(RedirectToAction("Delete", new { id = id, saveChancesError = true }));
            }
            return(RedirectToAction("Index"));
        }
Example #10
0
        public async Task ShouldUpdateCommitteeSuccess()
        {
            CommitteeModel committeeModel = committeeDefaults.ReturnCommitteeModelData();

            _moqCommitteeDomain.Setup(x => x.CheckNameExist(It.IsAny <string>(), It.IsAny <string>(), 0))
            .Returns(() =>
            {
                return(Task.FromResult <bool>(false));
            });
            _moqCommitteeQueries.Setup(x => x.GetById(It.IsAny <int>()))
            .Returns(() =>
            {
                return(Task.FromResult <Committee>(committeeDefaults.GetCommitteeData()));
            });
            await _sut.UpdateAsync(committeeModel);

            _moqCommandRepository.Verify(m => m.SaveAsync(), Times.Once);
        }
        // GET: /CommitteeModel/Delete/5
        public async Task <ActionResult> Delete(int?id, bool?saveChangesError = false)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (saveChangesError.GetValueOrDefault())
            {
                ViewBag.ErrorMessage = "Delete Failed. Please try again";
            }
            CommitteeModel committeemodel = await db.Committees.FindAsync(id);

            if (committeemodel == null)
            {
                return(HttpNotFound());
            }
            return(View(committeemodel));
        }
Example #12
0
        public JsonResult GetCommitteeList(CommitteeModel model)
        {
            var objUser = db.Users.Where(x => x.UserName == User.Identity.Name).FirstOrDefault();

            if (objUser.Member_Id != null && objUser.Committee_Id != null)
            {
                List <Committee>      committee = db.Committees.ToList();
                List <CommitteeModel> vm        = committee.Where(x => x.Id == objUser.Committee_Id).Select(x => new CommitteeModel
                {
                    Name          = x.Name,
                    Id            = x.Id,
                    Created_Date  = x.Created_Date,
                    Duration_Date = x.Duration_Date,
                    Status        = x.Status
                }).ToList();
                return(Json(vm, JsonRequestBehavior.AllowGet));
            }
            else if (model.OrganizationId != 0)
            {
                List <Committee>      committee = db.Committees.Where(x => x.Organization_Id == model.OrganizationId).ToList();
                List <CommitteeModel> vm        = committee.Select(x => new CommitteeModel
                {
                    Name          = x.Name,
                    Id            = x.Id,
                    Created_Date  = x.Created_Date,
                    Duration_Date = x.Duration_Date,
                    Status        = x.Status
                }).ToList();
                return(Json(vm, JsonRequestBehavior.AllowGet));
            }
            else
            {
                List <Committee>      committee = db.Committees.ToList();
                List <CommitteeModel> vm        = committee.Select(x => new CommitteeModel
                {
                    Name          = x.Name,
                    Id            = x.Id,
                    Created_Date  = x.Created_Date,
                    Duration_Date = x.Duration_Date,
                    Status        = x.Status
                }).ToList();
                return(Json(vm, JsonRequestBehavior.AllowGet));
            }
        }
Example #13
0
        public async Task <ActionResult> EditAsync(CommitteeModel committeeModel)
        {
            if (string.IsNullOrEmpty(committeeModel.CommitteeName))
            {
                ViewData.Add("CommitteeTypeId", committeeModel.CommitteeTypeIdString);
                return(View(committeeModel));
            }
            else
            {
                committeeModel.CommitteeName = committeeModel.CommitteeName.Trim();
            }
            if (!ModelState.IsValid)
            {
                AddError(Resources.SharedResources.ErrorMessages.ModelDataError);
                return(View(committeeModel));
            }
            try
            {
                committeeModel.CommitteeTypeId = Util.Decrypt(committeeModel.CommitteeTypeIdString);
                committeeModel.CommitteeId     = Util.Decrypt(committeeModel.CommitteeIdString);
                var committee = await _ApiClient.PostAsync <CommitteeModel>("Committee/Update", null, committeeModel);

                ClearCommitteesCache();

                AddMessage(string.Format(Resources.CommitteeResources.Messages.CommitteeEdited, committeeModel.CommitteeTypeName));
                return(RedirectToAction(nameof(Index), new { CommitteeTypeId = committeeModel.CommitteeTypeIdString }));
            }
            catch (AuthorizationException ex)
            {
                throw ex;
            }
            catch (BusinessRuleException ex)
            {
                AddError(ex.Message);
                ViewData.Add("CommitteeTypeId", Util.Encrypt(committeeModel.CommitteeTypeId));
                return(View(committeeModel));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString(), ex);
                AddError(Resources.TenderResources.ErrorMessages.UnexpectedError);
                return(RedirectToAction(nameof(Index), new { CommitteeTypeId = committeeModel.CommitteeTypeIdString }));
            }
        }
Example #14
0
        public IEnumerable <CommitteeModel> GetallCommittebymemberId(long id)
        {
            var data =
                _objRepository.GetAllMembersToCommittee()
                .Where(a => a.CommitteeMember.Id == id).ToList();

            var newmemberlist = new List <CommitteeModel>();

            foreach (var items in data)
            {
                var member = new CommitteeModel {
                    ComitteeName = items.Committee.ComitteeName
                };

                newmemberlist.Add(member);
            }

            return(newmemberlist);
        }
        public async Task <ActionResult> Edit([Bind(Include = "CommitteeModelID,CommitteeName,CurrentStatus")] CommitteeModel committeemodel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Entry(committeemodel).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException /* dex */)
            {
                // Log the error
                ModelState.AddModelError("", "Unable to save chanes. Please try again.");
            }

            return(View(committeemodel));
        }
        public ActionResult CreateStandalone([Bind(Include = "CommitteeName,CurrentStatus")] CommitteeModel committee)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Committees.Add(committee);
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException /* dex */)
            {
                // Log the error
                ModelState.AddModelError("", "Unable to save the chances. Please try again.");
            }

            return(View(committee));
        }
Example #17
0
        //internal static Task GetAsync(CommitteeSearchCriteria criteria)
        //{
        //   throw new NotImplementedException();
        //}

        // Create New Committee
        public static async Task CreateAsync(CommitteeModel committee)
        {
            await _connect.PostAsync("Committee", committee);
        }
Example #18
0
 //// Update Committee
 public static async Task  UpdateAsync(CommitteeModel committee)
 {
     await _connect.PostAsync("Committee/Update/", committee);
 }
Example #19
0
        public async Task <ActionResult> CreateAsync(CommitteeModel committeeModel)
        {
            ModelState.Remove("CommitteeTypeId");
            if (string.IsNullOrEmpty(committeeModel.CommitteeName))
            {
                ViewData.Add("CommitteeTypeId", committeeModel.CommitteeTypeIdString);
                return(View(committeeModel));
            }
            else
            {
                committeeModel.CommitteeName = committeeModel.CommitteeName.Trim();
            }
            if (!ModelState.IsValid)
            {
                AddError(Resources.SharedResources.ErrorMessages.ModelDataError);
                return(View(committeeModel));
            }
            try
            {
                committeeModel.CommitteeTypeId   = Util.Decrypt(committeeModel.CommitteeTypeIdString);
                committeeModel.AgencyCode        = User.UserAgency();
                committeeModel.RelatedAgencyCode = User.UserRelatedAgencyCode();
                await _ApiClient.PostAsync("Committee", null, committeeModel);

                ClearCommitteesCache();
                var message = "";
                switch ((Enums.CommitteeType)Util.Decrypt(committeeModel.CommitteeTypeIdString))
                {
                case Enums.CommitteeType.TechincalCommittee:
                    message = Messages.TechnicalCommitteeAdded;
                    break;

                case Enums.CommitteeType.OpenOfferCommittee:
                    message = Messages.OpenOfferCommitteeAdded;
                    break;

                case Enums.CommitteeType.CheckOfferCommittee:
                    message = Messages.CheckOfferCommitteeAdded;
                    break;

                case Enums.CommitteeType.BlockCommittee:
                    message = Messages.BlockCommitteeAdded;
                    break;

                case Enums.CommitteeType.PurchaseCommittee:
                    message = Messages.PurchaseCommitteeAdded;
                    break;

                case Enums.CommitteeType.PreQualificationCommittee:
                    message = Messages.PreQualificationCommitteeAdd;
                    break;

                default:
                    message = string.Format(Messages.CommitteeSaved, committeeModel.CommitteeName);
                    break;
                }
                AddMessage(message);
                return(RedirectToAction(nameof(Index), new { CommitteeTypeId = committeeModel.CommitteeTypeIdString }));
            }
            catch (AuthorizationException ex)
            {
                throw ex;
            }
            catch (BusinessRuleException ex)
            {
                AddError(ex.Message);
                ViewData.Add("CommitteeTypeId", Util.Encrypt(committeeModel.CommitteeTypeId));
                return(View(committeeModel));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString(), ex);
                AddError(Resources.TenderResources.ErrorMessages.UnexpectedError);
                return(RedirectToAction(nameof(Index), new { CommitteeTypeId = committeeModel.CommitteeTypeIdString }));
            }
        }