コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Title,Date,StarCount")] cRatings cRatings)
        {
            if (id != cRatings.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cRatings);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!cRatingsExists(cRatings.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cRatings));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("ID,Title,Date,StarCount")] cRatings cRatings)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cRatings);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cRatings));
        }
コード例 #3
0
        /// <summary>
        /// Creates a cRatings object. It will be saved in permanent storage only
        /// on calling Save()
        /// </summary>
        /// <returns>cRatings object</returns>
        public static cRatings Create()
        {
            cRatings oObj = new cRatings();

            SecurityCheck((int)enRatings_Action.Create);

            // Create an object in memory, will be saved to storage on calling Save()
            oObj.m_bCreating = true;
            oObj.m_bInvalid  = false;
            return(oObj);
        }
コード例 #4
0
        /// <summary>
        /// Ensures that an object with the specified name exists, while creating other properties are set to their default values
        /// </summary>
        /// <param name="i_sName">Name</param>
        /// <returns>cRatings object</returns>
        public static cRatings CreateIfRequiredAndGet(string i_sName)
        {
            cRatings oObj = cRatings.Get_Name(i_sName);

            if (oObj == null)
            {
                oObj       = cRatings.Create();
                oObj.sName = i_sName;
                oObj.Save();
            }
            return(oObj);
        }
コード例 #5
0
        /// <summary>
        /// Finds and return cRatings objects matching the specified criteria
        /// </summary>
        /// <param name="i_oFilter">Filter criteria (WHERE clause)</param>
        /// <returns>cRatings objects</returns>
        public static List <cRatings> Find(cFilter i_oFilter)
        {
            DataTable       dt = Find_DataTable(i_oFilter, null);
            List <cRatings> l  = new List <cRatings>();
            cRatings        oObj;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                oObj                   = new cRatings();
                oObj.m_iID             = Convert.ToInt32(dt.Rows[i]["iID"]);
                oObj.m_sName           = dt.Rows[i]["sName"].ToString();
                oObj.m_dtCreatedOn     = Convert.ToDateTime(dt.Rows[i]["dtCreatedOn"]);
                oObj.m_dtLastUpdatedOn = Convert.ToDateTime(dt.Rows[i]["dtLastUpdatedOn"]);

                oObj.m_sRatingName = Convert.ToString(dt.Rows[i]["sRatingName"]);
                oObj.m_bIsActive   = Convert.ToBoolean(dt.Rows[i]["bIsActive"]);
                oObj.m_bInvalid    = false;
                l.Add(oObj);
            }
            return(l);
        }