示例#1
0
        public CreateOutput <DivisionDto, long> Create(CreateInput <DivisionDto, long> input)
        {
            Division newDivisionEntity = input.Entity.MapTo <Division>();

            newDivisionEntity.IsDefault = false;
            newDivisionEntity.IsActive  = true;

            if (!DivisionPolicy.CanCreateEntity(newDivisionEntity))
            {
                throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionCreateDenied, "\"Division\"");
            }

            DivisionRepository.Includes.Add(r => r.LastModifierUser);
            DivisionRepository.Includes.Add(r => r.CreatorUser);
            DivisionRepository.Includes.Add(r => r.Teams);

            DivisionDto newDivisionDto = (DivisionRepository.Insert(newDivisionEntity)).MapTo <DivisionDto>();

            DivisionRepository.Includes.Clear();

            return(new CreateOutput <DivisionDto, long>()
            {
                CreatedEntity = newDivisionDto
            });
        }
示例#2
0
 public void InitDivisionTest()
 {
     context = new CSBCDbContext();
     var repDivision = new DivisionRepository(context);
     var division = new Division
     {
         Div_Desc = "Unit Test",
         CompanyID = 1,
         Gender = "M",
         MinDate = DateTime.Now,
         MaxDate = DateTime.Now.AddDays(60)
     };
     var divisionret = repDivision.Insert(division);
     Assert.IsTrue(divisionret != null);
 }
示例#3
0
 //protected void btnSave_Click(object sender, System.EventArgs e)
 //{
 //    lblError.Text = "";
 //    Session["ErrorMSG"] = "";
 //    if (DivisionId > 0)
 //    {
 //        UpdDivision();
 //    }
 //    else
 //    {
 //        AddDivision();
 //    }
 //}
 //private void AddDivision()
 //{
 //    if (errorRTN() == true)
 //    {
 //        MsgBox("ERROR: " + lblError.Text);
 //        return;
 //    }
 //    if (string.IsNullOrEmpty(Session["ErrorMsg"].ToString()))
 //        ADDRow();
 //    if (string.IsNullOrEmpty(Session["ErrorMsg"].ToString()))
 //        //Interaction.MsgBox("New Record Added Successfully");
 //        if (string.IsNullOrEmpty(Session["ErrorMsg"].ToString()))
 //            LoadTeams(DivisionId);
 //    if (string.IsNullOrEmpty(Session["ErrorMsg"].ToString()))
 //        LoadRow(DivisionId);
 //    if (String.IsNullOrEmpty(Session["ErrorMsg"].ToString()))
 //        ReassignDivision(DivisionId);
 //    if (string.IsNullOrEmpty(Session["ErrorMsg"].ToString()))
 //        LoadDivisions();
 //    lblError.Text = Session["ErrorMsg"].ToString();
 //}
 //private void UpdDivision()
 //{
 //    if (errorRTN() == true)
 //    {
 //        //Interaction.MsgBox("ERROR: " + lblError.Text);
 //        return;
 //    }
 //    if (String.IsNullOrEmpty(Session["ErrorMsg"].ToString()))
 //    {
 //        UpdRow(DivisionId);
 //        //Interaction.MsgBox("Changes successfully completed");
 //        LoadTeams(DivisionId);
 //        LoadRow(DivisionId);
 //        ReassignDivision(DivisionId);
 //        LoadDivisions();
 //    }
 //    else
 //    {
 //        lblError.Text = Session["ErrorMsg"].ToString();
 //    }
 //}
 protected void btnSave_Command(object sender, CommandEventArgs e)
 {
     var division = new Division();
     DateTime date;
     if (lblDivisionID.Value == "")
         division.DivisionID = 0;
     else
         division.DivisionID = Convert.ToInt32(lblDivisionID.Value);
     division.CompanyID = Master.CompanyId;
     division.SeasonID = Master.SeasonId;
     division.Div_Desc = txtName.Text;
     division.MinDate = DateTime.Parse(txtMinDate.Text);
     division.MaxDate = DateTime.Parse(txtMaxDate.Text);
     if (radGender.SelectedIndex == 0)
         division.Gender = "M";
     if (radGender.SelectedIndex == 1)
         division.Gender = "F";
     if (DateTime.TryParse(txtMinDate2.Text, out date))
         division.MinDate2 = date;
     DateTime goodDate;
     if (DateTime.TryParse(txtMaxDate2.Text, out goodDate))
         division.MaxDate2 = DateTime.Parse(txtMaxDate2.Text);
     if (radGender2.SelectedIndex == 0)
         division.Gender2 = "M";
     if (radGender2.SelectedIndex == 1)
         division.Gender2 = "F";
     division.DraftVenue = txtVenue.Text;
     if (DateTime.TryParse(txtDate.Text, out date))
         division.DraftDate = date;
     division.DraftTime = txtTime.Text;
     division.DirectorID = Int32.Parse(cboAD.SelectedValue);
     division.CoDirectorID = 0;
     //cboAD.SelectedValue
     division.CreatedUser = Session["UserName"].ToString();
     using (var db = new CSBCDbContext())
     {
         try
         {
             var rep = new DivisionRepository(db);
             if (division.DivisionID == 0)
             {
                 var newDivision = rep.Insert(division);
                 lblDivisionID.Value = newDivision.DivisionID.ToString();
             }
             else
                 rep.Update(division);
         }
         catch (Exception ex)
         {
             Console.WriteLine("Unable to save" + ex.InnerException);
         }
     }
     ReassignDivision(DivisionId);
     LoadDivisions();
 }
        //POST
        public IHttpActionResult Post(Division division)
        {
            var post = divisionRepository.Insert(division);

            return(Ok(post));
        }