Пример #1
0
        public static OrganizersModel TranslateAsOrganizer(this SqlDataReader reader, bool isList = false)
        {
            if (!isList)
            {
                if (!reader.HasRows)
                {
                    return(null);
                }
                reader.Read();
            }
            var item = new OrganizersModel();

            if (reader.IsColumnExists("Id"))
            {
                item.Id = SqlHelper.GetNullableInt32(reader, "Id");
            }

            if (reader.IsColumnExists("Organizer"))
            {
                item.Organizer = SqlHelper.GetNullableString(reader, "Organizer");
            }

            if (reader.IsColumnExists("Adress"))
            {
                item.Adress = SqlHelper.GetNullableString(reader, "Adress");
            }

            return(item);
        }
        public IActionResult saveOrganizer([FromBody] OrganizersModel organizer)
        {
            if (organizer == null)
            {
                return(BadRequest());
            }

            var msg  = new Message <OrganizersModel>();
            var data = DbClientFactory <MyEventsDBClient> .Instance.SaveOrganizer(organizer,
                                                                                  configuration.GetSection("MySettings").GetSection("DbConnection").Value);

            if (data == "c200")
            {
                msg.IsSuccess = true;
                if (organizer.Id == 0)
                {
                    msg.ReturnMessage = "Organizer saved successfully";
                }
                else
                {
                    msg.ReturnMessage = "Organizer updated successfully";
                }
            }
            else if (data == "c203")
            {
                msg.IsSuccess     = false;
                msg.ReturnMessage = "Updated organizer not found";
            }
            return(Ok(msg));
        }