Exemplo n.º 1
0
        public async Task <IHttpActionResult> AddFestival(FestivalModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                logger.Info($"Adding new festival: {model.Name}");
                var festivalEntity = new Festival
                {
                    Name = model.Name
                };
                _templeDatabaseContext.Festival.Add(festivalEntity);
                await _templeDatabaseContext.SaveChangesAsync();

                model.Id = festivalEntity.Id;
                return(Ok(model));
            }
            catch (Exception exception)
            {
                logger.Error($"Error adding new festival {model.Name}, Exception: {exception}");
                return(BadRequest($"Error adding new festival: {model.Name}"));
            }
        }
Exemplo n.º 2
0
        protected void GridViewPoinPenilain_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Add")
            {
                try
                {

                    GridViewRow row = GridViewPoinPenilaian.FooterRow;
                    int getId = FestivalModel.GetMaksID(HiddenID.Value);
                    getId++;
                    TextBox poinpenilaian = (TextBox)row.FindControl("TextBoxPoinPenilaian");
                    var fd = new FestivalDetail(HiddenID.Value, getId, poinpenilaian.Text);
                    Employee emp = (Employee)Session["Login"];
                    fd.CreatedBy = emp.employeeid;
                    fd.UpdatedBy = emp.employeeid;
                    int i = FestivalControl.InsertFestivalDetail(fd);
                    bindGridViewFestivalDetail(HiddenID.Value);
                    if (i > 0)
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "showPop('Data telah disimpan');", true);

                
                
                }
                catch (Exception ex)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "showPop('" + ex.Message + "');", true);
                }
            }
        }
Exemplo n.º 3
0
        protected void ButtonSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                int rowCount = 0;
                if (String.IsNullOrEmpty(HiddenID.Value))
                {
                    int i = FestivalModel.GetMaksID();
                    i++;
                    int temp = i;
                    string enol = "00";
                    int digit = 0;
                    while (temp != 0)
                    {
                        temp /= 10;
                        digit++;
                    }
                    if (digit == 1)
                        enol = "00";
                    else if (digit == 2)
                        enol = "0";
                    else if (digit == 3)
                        enol = "";
                    string newid = "FS" + enol + i;
                    FestivalClass newfestival = new FestivalClass(newid, TextBoxNamaFestival.Text, RadioButtonListSistem.Text, TextBoxDescription.Text);
                    Employee emp = (Employee)Session["Login"];
                    newfestival.CreatedBy = emp.employeeid;
                    newfestival.UpdatedBy = emp.employeeid;
                    rowCount=FestivalControl.InsertFestival(newfestival);
                    clearField();
                    bindGridViewFestival();
                    bindGridViewFestivalDetail("");
                }
                else
                {
                    FestivalClass newfestival = new FestivalClass(HiddenID.Value, TextBoxNamaFestival.Text, RadioButtonListSistem.Text, TextBoxDescription.Text);
                    Employee emp = (Employee)Session["Login"];
                    newfestival.UpdatedBy = emp.employeeid;
                    rowCount= FestivalControl.UpdateFestival(newfestival);
                    bindGridViewFestival();
                    clearField();
                    bindGridViewFestivalDetail("");
                }
                if (rowCount > 0)
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "showPop('Data telah disimpan');", true);

            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "showPop('" + ex.Message + "');", true);
            }
            
        }
Exemplo n.º 4
0
        public async Task <IHttpActionResult> UpdateFestival(FestivalModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                logger.Info($"Updating festival:{model.Id}, {model.Name}");
                var festivalEntity = await _templeDatabaseContext.Festival.FirstAsync(t => t.Id == model.Id);

                festivalEntity.Name = model.Name;
                await _templeDatabaseContext.SaveChangesAsync();

                return(Ok(model));
            }
            catch (Exception exception)
            {
                logger.Error($"Error updating festival {model.Name}, Exception: {exception}");
                return(BadRequest($"Error updating festival: {model.Name}"));
            }
        }